mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Remove access to PlotSquared#IMP and rename IPlotMain to PlotPlatform, then rename PlotSquared#imp() to PlotSquared#platform()
This commit is contained in:
parent
b5818bfefc
commit
d76c9dad52
@ -59,7 +59,7 @@ 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.PlotPlatform;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.backup.BackupManager;
|
||||
import com.plotsquared.core.backup.NullBackupManager;
|
||||
@ -159,7 +159,7 @@ import static com.plotsquared.core.util.PremiumVerification.getResourceID;
|
||||
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
||||
import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<Player> {
|
||||
public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPlatform<Player> {
|
||||
|
||||
private static final int BSTATS_ID = 1404;
|
||||
@Getter private static WorldEdit worldEdit;
|
||||
@ -214,7 +214,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
|
||||
new PlotSquared(this, "Bukkit");
|
||||
|
||||
if (PlotSquared.get().IMP.getServerVersion()[1] < 13) {
|
||||
if (PlotSquared.platform().getServerVersion()[1] < 13) {
|
||||
System.out.println(
|
||||
"You can't use this version of PlotSquared on a server less than Minecraft 1.13.2.");
|
||||
System.out
|
||||
@ -267,7 +267,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
|
||||
final SQLiteUUIDService legacyUUIDService;
|
||||
if (Settings.UUID.LEGACY_DATABASE_SUPPORT && MainUtil
|
||||
.getFile(PlotSquared.get().IMP.getDirectory(), "usercache.db").exists()) {
|
||||
.getFile(PlotSquared.platform().getDirectory(), "usercache.db").exists()) {
|
||||
legacyUUIDService = new SQLiteUUIDService("usercache.db");
|
||||
} else {
|
||||
legacyUUIDService = null;
|
||||
@ -758,7 +758,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
if (currentPlotId != null) {
|
||||
entity.setMetadata("shulkerPlot",
|
||||
new FixedMetadataValue(
|
||||
(Plugin) PlotSquared.get().IMP, currentPlotId));
|
||||
(Plugin) PlotSquared.platform(), currentPlotId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -884,7 +884,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
if (id != null && id.equalsIgnoreCase("single")) {
|
||||
result = new SingleWorldGenerator();
|
||||
} else {
|
||||
result = PlotSquared.get().IMP.getDefaultGenerator();
|
||||
result = PlotSquared.platform().getDefaultGenerator();
|
||||
if (!PlotSquared.get().setupPlotWorld(worldName, id, result)) {
|
||||
return null;
|
||||
}
|
||||
@ -983,7 +983,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
}
|
||||
return new BukkitPlotGenerator(world, gen);
|
||||
} else {
|
||||
return new BukkitPlotGenerator(world, PlotSquared.get().IMP.getDefaultGenerator());
|
||||
return new BukkitPlotGenerator(world, PlotSquared.platform().getDefaultGenerator());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1118,11 +1118,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
return BukkitUtil.getPlayer((OfflinePlayer) player);
|
||||
}
|
||||
if (player instanceof String) {
|
||||
return (PlotPlayer<Player>) PlotSquared.imp().getPlayerManager()
|
||||
return (PlotPlayer<Player>) PlotSquared.platform().getPlayerManager()
|
||||
.getPlayerIfExists((String) player);
|
||||
}
|
||||
if (player instanceof UUID) {
|
||||
return (PlotPlayer<Player>) PlotSquared.imp().getPlayerManager()
|
||||
return (PlotPlayer<Player>) PlotSquared.platform().getPlayerManager()
|
||||
.getPlayerIfExists((UUID) player);
|
||||
}
|
||||
return null;
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.bukkit.entity;
|
||||
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.BukkitPlatform;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -53,7 +53,7 @@ public class TeleportEntityWrapper extends EntityWrapper {
|
||||
getEntity().setInvulnerable(invulnerableOld);
|
||||
getEntity().setFireTicks(fireTicksOld);
|
||||
getEntity().setTicksLived(livingTicksOld);
|
||||
getEntity().removeMetadata("ps-tmp-teleport", BukkitMain.getPlugin(BukkitMain.class));
|
||||
getEntity().removeMetadata("ps-tmp-teleport", BukkitPlatform.getPlugin(BukkitPlatform.class));
|
||||
}
|
||||
return getEntity();
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class TeleportEntityWrapper extends EntityWrapper {
|
||||
this.fireTicksOld = this.getEntity().getFireTicks();
|
||||
this.livingTicksOld = this.getEntity().getTicksLived();
|
||||
this.getEntity().setMetadata("ps-tmp-teleport",
|
||||
new FixedMetadataValue(BukkitMain.getPlugin(BukkitMain.class), oldLocation));
|
||||
new FixedMetadataValue(BukkitPlatform.getPlugin(BukkitPlatform.class), oldLocation));
|
||||
final Chunk newChunk = getNewChunk();
|
||||
this.getEntity().teleport(
|
||||
new Location(newChunk.getWorld(), newChunk.getX() << 4, 5000, newChunk.getZ() << 4));
|
||||
|
@ -61,7 +61,7 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
|
||||
}
|
||||
|
||||
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||
return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotArea(world, id, min, max);
|
||||
return PlotSquared.platform().getDefaultGenerator().getNewPlotArea(world, id, min, max);
|
||||
}
|
||||
|
||||
@Override public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings) {
|
||||
|
@ -73,7 +73,7 @@ public class ChunkListener implements Listener {
|
||||
this.mustSave = classChunk.getField("mustSave");
|
||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
} catch (Throwable ignored) {
|
||||
PlotSquared.debug(PlotSquared.get().IMP.getPluginName()
|
||||
PlotSquared.debug(PlotSquared.platform().getPluginName()
|
||||
+ "/Server not compatible for chunk processor trim/gc");
|
||||
|
||||
Settings.Chunk_Processor.AUTO_TRIM = false;
|
||||
|
@ -92,7 +92,7 @@ public class EntitySpawnListener implements Listener {
|
||||
if (meta.isEmpty()) {
|
||||
if (PlotSquared.get().hasPlotArea(world.getName())) {
|
||||
entity.setMetadata(KEY,
|
||||
new FixedMetadataValue((Plugin) PlotSquared.get().IMP, entity.getLocation()));
|
||||
new FixedMetadataValue((Plugin) PlotSquared.platform(), entity.getLocation()));
|
||||
}
|
||||
} else {
|
||||
org.bukkit.Location origin = (org.bukkit.Location) meta.get(0).value();
|
||||
@ -161,7 +161,7 @@ public class EntitySpawnListener implements Listener {
|
||||
case SHULKER:
|
||||
if (!entity.hasMetadata("shulkerPlot")) {
|
||||
entity.setMetadata("shulkerPlot",
|
||||
new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot.getId()));
|
||||
new FixedMetadataValue((Plugin) PlotSquared.platform(), plot.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
int z = bloc.getBlockZ();
|
||||
int distance = Bukkit.getViewDistance() * 16;
|
||||
|
||||
for (final PlotPlayer<?> player : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
||||
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||
Location location = player.getLocation();
|
||||
if (location.getWorld().equals(world)) {
|
||||
if (16 * Math.abs(location.getX() - x) / 16 > distance
|
||||
@ -355,18 +355,18 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (plot.isMerged()) {
|
||||
disable = true;
|
||||
for (UUID owner : plot.getOwners()) {
|
||||
if (PlotSquared.imp().getPlayerManager().getPlayerIfExists(owner) != null) {
|
||||
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(owner) != null) {
|
||||
disable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
disable = PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs()) == null;
|
||||
disable = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs()) == null;
|
||||
}
|
||||
}
|
||||
if (disable) {
|
||||
for (UUID trusted : plot.getTrusted()) {
|
||||
if (PlotSquared.imp().getPlayerManager().getPlayerIfExists(trusted) != null) {
|
||||
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(trusted) != null) {
|
||||
disable = false;
|
||||
break;
|
||||
}
|
||||
@ -379,7 +379,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (Settings.Redstone.DISABLE_UNOCCUPIED) {
|
||||
for (final PlotPlayer<?> player : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
||||
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||
if (plot.equals(player.getCurrentPlot())) {
|
||||
return;
|
||||
}
|
||||
@ -794,7 +794,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
} else if (toPlot != null) {
|
||||
vehicle.setMetadata("plot",
|
||||
new FixedMetadataValue((Plugin) PlotSquared.get().IMP, toPlot));
|
||||
new FixedMetadataValue((Plugin) PlotSquared.platform(), toPlot));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -960,7 +960,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Set<Player> recipients = event.getRecipients();
|
||||
recipients.clear();
|
||||
Set<Player> spies = new HashSet<>();
|
||||
for (final PlotPlayer<?> pp : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
||||
for (final PlotPlayer<?> pp : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||
if (pp.getAttribute("chatspy")) {
|
||||
spies.add(((BukkitPlayer) pp).player);
|
||||
} else {
|
||||
@ -1092,7 +1092,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
.equals(EntityType.MINECART_TNT)) {
|
||||
if (!near.hasMetadata("plot")) {
|
||||
near.setMetadata("plot",
|
||||
new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot));
|
||||
new FixedMetadataValue((Plugin) PlotSquared.platform(), plot));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2185,7 +2185,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
} else if (event.getTo() == Material.AIR) {
|
||||
event.getEntity()
|
||||
.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot));
|
||||
.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2426,7 +2426,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
||||
entity
|
||||
.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot));
|
||||
.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class Placeholders extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
@Override public String onPlaceholderRequest(Player p, String identifier) {
|
||||
final PlotPlayer pl = PlotSquared.imp().getPlayerManager().getPlayerIfExists(p.getUniqueId());
|
||||
final PlotPlayer pl = PlotSquared.platform().getPlayerManager().getPlayerIfExists(p.getUniqueId());
|
||||
|
||||
if (pl == null) {
|
||||
return "";
|
||||
|
@ -143,7 +143,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
private void callEvent(@NotNull final Event event) {
|
||||
final RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
|
||||
for (final RegisteredListener listener : listeners) {
|
||||
if (listener.getPlugin().getName().equals(PlotSquared.imp().getPluginName())) {
|
||||
if (listener.getPlugin().getName().equals(PlotSquared.platform().getPluginName())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
|
@ -83,8 +83,8 @@ public class BukkitEconHandler extends EconHandler {
|
||||
* @deprecated Use {@link PermHandler#hasPermission(String, String, String)} instead
|
||||
*/
|
||||
@Deprecated @Override public boolean hasPermission(String world, String player, String perm) {
|
||||
if (PlotSquared.imp().getPermissionHandler() != null) {
|
||||
return PlotSquared.imp().getPermissionHandler().hasPermission(world, player, perm);
|
||||
if (PlotSquared.platform().getPermissionHandler() != null) {
|
||||
return PlotSquared.platform().getPermissionHandler().hasPermission(world, player, perm);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.BukkitPlatform;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.generator.AugmentedUtils;
|
||||
import com.plotsquared.core.location.Location;
|
||||
@ -94,7 +94,7 @@ public class BukkitRegionManager extends RegionManager {
|
||||
PlotSquared.debug("Attempting to make an asynchronous call to getLoadedChunks."
|
||||
+ " Will halt the calling thread until completed.");
|
||||
semaphore.acquire();
|
||||
Bukkit.getScheduler().runTask(BukkitMain.getPlugin(BukkitMain.class), () -> {
|
||||
Bukkit.getScheduler().runTask(BukkitPlatform.getPlugin(BukkitPlatform.class), () -> {
|
||||
for (Chunk chunk : Objects.requireNonNull(Bukkit.getWorld(world))
|
||||
.getLoadedChunks()) {
|
||||
BlockVector2 loc = BlockVector2.at(chunk.getX() >> 5, chunk.getZ() >> 5);
|
||||
|
@ -200,7 +200,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Objects.requireNonNull(PlotSquared.imp()).getWorldManager()
|
||||
Objects.requireNonNull(PlotSquared.platform()).getWorldManager()
|
||||
.handleWorldCreation(object.world, object.setupGenerator);
|
||||
|
||||
if (Bukkit.getWorld(world) != null) {
|
||||
@ -313,7 +313,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Objects.requireNonNull(PlotSquared.imp()).getWorldManager()
|
||||
Objects.requireNonNull(PlotSquared.platform()).getWorldManager()
|
||||
.handleWorldCreation(builder.worldName(), builder.generatorName());
|
||||
|
||||
if (Bukkit.getWorld(world) != null) {
|
||||
|
@ -25,15 +25,15 @@
|
||||
*/
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.BukkitPlatform;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BukkitTaskManager extends TaskManager {
|
||||
|
||||
private final BukkitMain bukkitMain;
|
||||
private final BukkitPlatform bukkitMain;
|
||||
|
||||
public BukkitTaskManager(BukkitMain bukkitMain) {
|
||||
public BukkitTaskManager(BukkitPlatform bukkitMain) {
|
||||
this.bukkitMain = bukkitMain;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.BukkitPlatform;
|
||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
@ -120,7 +120,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
lastPlayer = null;
|
||||
lastPlotPlayer = null;
|
||||
// Make sure that it's removed internally
|
||||
PlotSquared.imp().getPlayerManager().removePlayer(uuid);
|
||||
PlotSquared.platform().getPlayerManager().removePlayer(uuid);
|
||||
}
|
||||
|
||||
public static PlotPlayer<Player> getPlayer(@NonNull final OfflinePlayer op) {
|
||||
@ -271,7 +271,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
if (player == lastPlayer) {
|
||||
return lastPlotPlayer;
|
||||
}
|
||||
final PlayerManager<?, ?> playerManager = PlotSquared.imp().getPlayerManager();
|
||||
final PlayerManager<?, ?> playerManager = PlotSquared.platform().getPlayerManager();
|
||||
return ((BukkitPlayerManager) playerManager).getPlayer(player);
|
||||
}
|
||||
|
||||
@ -458,7 +458,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
} else if (world.getBlockAt(x, y, z - 1).getType().isSolid()) {
|
||||
facing = BlockFace.SOUTH;
|
||||
}
|
||||
if (PlotSquared.get().IMP.getServerVersion()[1] == 13) {
|
||||
if (PlotSquared.platform().getServerVersion()[1] == 13) {
|
||||
block.setType(Material.valueOf("WALL_SIGN"), false);
|
||||
} else {
|
||||
block.setType(Material.valueOf("OAK_WALL_SIGN"), false);
|
||||
@ -688,7 +688,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
consumer.accept(value);
|
||||
} else {
|
||||
Bukkit.getScheduler()
|
||||
.runTask(BukkitMain.getPlugin(BukkitMain.class), () -> consumer.accept(value));
|
||||
.runTask(BukkitPlatform.getPlugin(BukkitPlatform.class), () -> consumer.accept(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,6 @@ public class SetGenCB {
|
||||
.removeIf(blockPopulator -> blockPopulator instanceof BukkitAugmentedGenerator);
|
||||
}
|
||||
PlotSquared.get()
|
||||
.loadWorld(world.getName(), PlotSquared.get().IMP.getGenerator(world.getName(), null));
|
||||
.loadWorld(world.getName(), PlotSquared.platform().getGenerator(world.getName(), null));
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
|
||||
|
||||
public SQLiteUUIDService(final String fileName) {
|
||||
this.sqlite =
|
||||
new SQLite(MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), fileName));
|
||||
new SQLite(MainUtil.getFile(PlotSquared.platform().getDirectory(), fileName));
|
||||
try {
|
||||
this.sqlite.openConnection();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: ${name}
|
||||
main: com.plotsquared.bukkit.BukkitMain
|
||||
main: com.plotsquared.bukkit.BukkitPlatform
|
||||
api-version: "1.13"
|
||||
version: "${version}"
|
||||
load: STARTUP
|
||||
|
@ -57,7 +57,7 @@ import java.util.Map;
|
||||
*
|
||||
* @param <P> Player type
|
||||
*/
|
||||
public interface IPlotMain<P> extends ILogger {
|
||||
public interface PlotPlatform<P> extends ILogger {
|
||||
|
||||
/**
|
||||
* Logs a message to console.
|
@ -137,11 +137,13 @@ import java.util.zip.ZipInputStream;
|
||||
* An implementation of the core, with a static getter for easy access.
|
||||
*/
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
public class PlotSquared {
|
||||
public class PlotSquared<P> {
|
||||
|
||||
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
|
||||
private static PlotSquared instance;
|
||||
private static PlotSquared<?> instance;
|
||||
|
||||
// Implementation
|
||||
public final IPlotMain<?> IMP;
|
||||
private final PlotPlatform<P> platform;
|
||||
// Current thread
|
||||
private final Thread thread;
|
||||
// UUID pipelines
|
||||
@ -177,17 +179,17 @@ public class PlotSquared {
|
||||
/**
|
||||
* Initialize PlotSquared with the desired Implementation class.
|
||||
*
|
||||
* @param iPlotMain Implementation of {@link IPlotMain} used
|
||||
* @param iPlotMain Implementation of {@link PlotPlatform} used
|
||||
* @param platform The platform being used
|
||||
*/
|
||||
public PlotSquared(final IPlotMain iPlotMain, final String platform) {
|
||||
public PlotSquared(final PlotPlatform<P> iPlotMain, final String platform) {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("Cannot re-initialize the PlotSquared singleton");
|
||||
}
|
||||
instance = this;
|
||||
|
||||
this.thread = Thread.currentThread();
|
||||
this.IMP = iPlotMain;
|
||||
this.platform = iPlotMain;
|
||||
this.logger = iPlotMain;
|
||||
Settings.PLATFORM = platform;
|
||||
|
||||
@ -197,7 +199,7 @@ public class PlotSquared {
|
||||
ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket");
|
||||
|
||||
try {
|
||||
new ReflectionUtils(this.IMP.getNMSPackage());
|
||||
new ReflectionUtils(this.platform.getNMSPackage());
|
||||
try {
|
||||
URL url = PlotSquared.class.getProtectionDomain().getCodeSource().getLocation();
|
||||
this.jarFile = new File(
|
||||
@ -205,22 +207,22 @@ public class PlotSquared {
|
||||
.toURI().getPath());
|
||||
} catch (MalformedURLException | URISyntaxException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
this.jarFile = new File(this.IMP.getDirectory().getParentFile(), "PlotSquared.jar");
|
||||
this.jarFile = new File(this.platform.getDirectory().getParentFile(), "PlotSquared.jar");
|
||||
if (!this.jarFile.exists()) {
|
||||
this.jarFile = new File(this.IMP.getDirectory().getParentFile(),
|
||||
this.jarFile = new File(this.platform.getDirectory().getParentFile(),
|
||||
"PlotSquared-" + platform + ".jar");
|
||||
}
|
||||
}
|
||||
TaskManager.IMP = this.IMP.getTaskManager();
|
||||
TaskManager.IMP = this.platform.getTaskManager();
|
||||
|
||||
// World Util. Has to be done before config files are loaded
|
||||
WorldUtil.IMP = this.IMP.initWorldUtil();
|
||||
WorldUtil.IMP = this.platform.initWorldUtil();
|
||||
|
||||
if (!setupConfigs()) {
|
||||
return;
|
||||
}
|
||||
this.translationFile = MainUtil.getFile(this.IMP.getDirectory(),
|
||||
Settings.Paths.TRANSLATIONS + File.separator + IMP.getPluginName()
|
||||
this.translationFile = MainUtil.getFile(this.platform.getDirectory(),
|
||||
Settings.Paths.TRANSLATIONS + File.separator + this.platform.getPluginName()
|
||||
+ ".use_THIS.yml");
|
||||
Captions.load(this.translationFile);
|
||||
|
||||
@ -251,44 +253,44 @@ public class PlotSquared {
|
||||
// Kill entities
|
||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS
|
||||
|| Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
||||
this.IMP.runEntityTask();
|
||||
this.platform.runEntityTask();
|
||||
}
|
||||
if (Settings.Enabled_Components.EVENTS) {
|
||||
this.IMP.registerPlayerEvents();
|
||||
this.platform.registerPlayerEvents();
|
||||
}
|
||||
// Required
|
||||
this.IMP.registerWorldEvents();
|
||||
this.platform.registerWorldEvents();
|
||||
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
||||
this.IMP.registerChunkProcessor();
|
||||
this.platform.registerChunkProcessor();
|
||||
}
|
||||
// Create Event utility class
|
||||
eventDispatcher = new EventDispatcher();
|
||||
// create Hybrid utility class
|
||||
HybridUtils.manager = this.IMP.initHybridUtils();
|
||||
HybridUtils.manager = this.platform.initHybridUtils();
|
||||
// Inventory utility class
|
||||
InventoryUtil.manager = this.IMP.initInventoryUtil();
|
||||
InventoryUtil.manager = this.platform.initInventoryUtil();
|
||||
// create setup util class
|
||||
SetupUtils.manager = this.IMP.initSetupUtils();
|
||||
SetupUtils.manager = this.platform.initSetupUtils();
|
||||
// Set block
|
||||
GlobalBlockQueue.IMP =
|
||||
new GlobalBlockQueue(IMP.initBlockQueue(), 1, Settings.QUEUE.TARGET_TIME);
|
||||
new GlobalBlockQueue(this.platform.initBlockQueue(), 1, Settings.QUEUE.TARGET_TIME);
|
||||
GlobalBlockQueue.IMP.runTask();
|
||||
// Set chunk
|
||||
ChunkManager.manager = this.IMP.initChunkManager();
|
||||
RegionManager.manager = this.IMP.initRegionManager();
|
||||
ChunkManager.manager = this.platform.initChunkManager();
|
||||
RegionManager.manager = this.platform.initRegionManager();
|
||||
// Schematic handler
|
||||
SchematicHandler.manager = this.IMP.initSchematicHandler();
|
||||
SchematicHandler.manager = this.platform.initSchematicHandler();
|
||||
// Chat
|
||||
ChatManager.manager = this.IMP.initChatManager();
|
||||
ChatManager.manager = this.platform.initChatManager();
|
||||
// Commands
|
||||
if (Settings.Enabled_Components.COMMANDS) {
|
||||
this.IMP.registerCommands();
|
||||
this.platform.registerCommands();
|
||||
}
|
||||
// WorldEdit
|
||||
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
||||
try {
|
||||
if (this.IMP.initWorldEdit()) {
|
||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + IMP.getPluginName()
|
||||
if (this.platform.initWorldEdit()) {
|
||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + this.platform.getPluginName()
|
||||
+ " hooked into WorldEdit.");
|
||||
this.worldedit = WorldEdit.getInstance();
|
||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
||||
@ -324,7 +326,7 @@ public class PlotSquared {
|
||||
continue;
|
||||
}
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
this.IMP.setGenerator(world);
|
||||
this.platform.setGenerator(world);
|
||||
}
|
||||
}
|
||||
TaskManager.runTaskLater(() -> {
|
||||
@ -333,7 +335,7 @@ public class PlotSquared {
|
||||
continue;
|
||||
}
|
||||
if (!WorldUtil.IMP.isWorld(world) && !world.equals("*")) {
|
||||
debug("`" + world + "` was not properly loaded - " + IMP.getPluginName()
|
||||
debug("`" + world + "` was not properly loaded - " + this.platform.getPluginName()
|
||||
+ " will now try to load it properly: ");
|
||||
debug(
|
||||
" - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
|
||||
@ -341,7 +343,7 @@ public class PlotSquared {
|
||||
" - Your world management plugin may be faulty (or non existent)");
|
||||
debug(
|
||||
" This message may also be a false positive and could be ignored.");
|
||||
PlotSquared.this.IMP.setGenerator(world);
|
||||
PlotSquared.this.platform.setGenerator(world);
|
||||
}
|
||||
}
|
||||
}, 1);
|
||||
@ -373,7 +375,7 @@ public class PlotSquared {
|
||||
|
||||
PlotSquared.log(Captions.PREFIX + CaptionUtility
|
||||
.format(ConsolePlayer.getConsole(), Captions.ENABLED.getTranslated(),
|
||||
IMP.getPluginName()));
|
||||
this.platform.getPluginName()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -381,13 +383,13 @@ public class PlotSquared {
|
||||
*
|
||||
* @return instance of PlotSquared
|
||||
*/
|
||||
public static PlotSquared get() {
|
||||
public static PlotSquared<?> get() {
|
||||
return PlotSquared.instance;
|
||||
}
|
||||
|
||||
@NotNull public static IPlotMain<?> imp() {
|
||||
if (instance != null && instance.IMP != null) {
|
||||
return instance.IMP;
|
||||
@NotNull public static PlotPlatform<?> platform() {
|
||||
if (instance != null && instance.platform != null) {
|
||||
return instance.platform;
|
||||
}
|
||||
throw new IllegalStateException("Plot main implementation is missing");
|
||||
}
|
||||
@ -396,7 +398,7 @@ public class PlotSquared {
|
||||
* Log a message to the IPlotMain logger.
|
||||
*
|
||||
* @param message Message to log
|
||||
* @see IPlotMain#log(String)
|
||||
* @see PlotPlatform#log(String)
|
||||
*/
|
||||
public static void log(Object message) {
|
||||
if (message == null || (message instanceof Caption ?
|
||||
@ -415,7 +417,7 @@ public class PlotSquared {
|
||||
* Log a message to the IPlotMain logger.
|
||||
*
|
||||
* @param message Message to log
|
||||
* @see IPlotMain#log(String)
|
||||
* @see PlotPlatform#log(String)
|
||||
*/
|
||||
public static void debug(@Nullable Object message) {
|
||||
if (Settings.DEBUG) {
|
||||
@ -539,7 +541,7 @@ public class PlotSquared {
|
||||
return;
|
||||
}
|
||||
File file = new File(
|
||||
this.IMP.getDirectory() + File.separator + "persistent_regen_data_" + plotArea.getId()
|
||||
this.platform.getDirectory() + File.separator + "persistent_regen_data_" + plotArea.getId()
|
||||
+ "_" + plotArea.getWorldName());
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
@ -1137,13 +1139,13 @@ public class PlotSquared {
|
||||
} else if (worldSection != null) {
|
||||
String secondaryGeneratorName = worldSection.getString("generator.plugin");
|
||||
GeneratorWrapper<?> secondaryGenerator =
|
||||
this.IMP.getGenerator(world, secondaryGeneratorName);
|
||||
this.platform.getGenerator(world, secondaryGeneratorName);
|
||||
if (secondaryGenerator != null && secondaryGenerator.isFull()) {
|
||||
plotGenerator = secondaryGenerator.getPlotGenerator();
|
||||
} else {
|
||||
String primaryGeneratorName = worldSection.getString("generator.init");
|
||||
GeneratorWrapper<?> primaryGenerator =
|
||||
this.IMP.getGenerator(world, primaryGeneratorName);
|
||||
this.platform.getGenerator(world, primaryGeneratorName);
|
||||
if (primaryGenerator != null && primaryGenerator.isFull()) {
|
||||
plotGenerator = primaryGenerator.getPlotGenerator();
|
||||
} else {
|
||||
@ -1187,7 +1189,7 @@ public class PlotSquared {
|
||||
return;
|
||||
}
|
||||
PlotSquared.log(Captions.PREFIX + "&aDetected world load for '" + world + "'");
|
||||
String gen_string = worldSection.getString("generator.plugin", IMP.getPluginName());
|
||||
String gen_string = worldSection.getString("generator.plugin", platform.getPluginName());
|
||||
if (type == PlotAreaType.PARTIAL) {
|
||||
Set<PlotCluster> clusters =
|
||||
this.clusters_tmp != null ? this.clusters_tmp.get(world) : new HashSet<>();
|
||||
@ -1204,7 +1206,7 @@ public class PlotSquared {
|
||||
DBFunc.replaceWorld(world, world + ";" + name, pos1, pos2); // NPE
|
||||
|
||||
PlotSquared.log(Captions.PREFIX + "&3 - " + name + "-" + pos1 + "-" + pos2);
|
||||
GeneratorWrapper<?> areaGen = this.IMP.getGenerator(world, gen_string);
|
||||
GeneratorWrapper<?> areaGen = this.platform.getGenerator(world, gen_string);
|
||||
if (areaGen == null) {
|
||||
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
|
||||
}
|
||||
@ -1234,7 +1236,7 @@ public class PlotSquared {
|
||||
}
|
||||
return;
|
||||
}
|
||||
GeneratorWrapper<?> areaGen = this.IMP.getGenerator(world, gen_string);
|
||||
GeneratorWrapper<?> areaGen = this.platform.getGenerator(world, gen_string);
|
||||
if (areaGen == null) {
|
||||
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
|
||||
}
|
||||
@ -1296,8 +1298,8 @@ public class PlotSquared {
|
||||
clone.set(key, worldSection.get(key));
|
||||
}
|
||||
}
|
||||
String gen_string = clone.getString("generator.plugin", IMP.getPluginName());
|
||||
GeneratorWrapper<?> areaGen = this.IMP.getGenerator(world, gen_string);
|
||||
String gen_string = clone.getString("generator.plugin", platform.getPluginName());
|
||||
GeneratorWrapper<?> areaGen = this.platform.getGenerator(world, gen_string);
|
||||
if (areaGen == null) {
|
||||
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
|
||||
}
|
||||
@ -1485,7 +1487,7 @@ public class PlotSquared {
|
||||
*/
|
||||
public void copyFile(String file, String folder) {
|
||||
try {
|
||||
File output = this.IMP.getDirectory();
|
||||
File output = this.platform.getDirectory();
|
||||
if (!output.exists()) {
|
||||
output.mkdirs();
|
||||
}
|
||||
@ -1493,7 +1495,7 @@ public class PlotSquared {
|
||||
if (newFile.exists()) {
|
||||
return;
|
||||
}
|
||||
try (InputStream stream = this.IMP.getClass().getResourceAsStream(file)) {
|
||||
try (InputStream stream = this.platform.getClass().getResourceAsStream(file)) {
|
||||
byte[] buffer = new byte[2048];
|
||||
if (stream == null) {
|
||||
try (ZipInputStream zis = new ZipInputStream(
|
||||
@ -1593,7 +1595,7 @@ public class PlotSquared {
|
||||
list.add(chunks);
|
||||
list.add(HybridUtils.height);
|
||||
File file = new File(
|
||||
this.IMP.getDirectory() + File.separator + "persistent_regen_data_" + HybridUtils.area
|
||||
this.platform.getDirectory() + File.separator + "persistent_regen_data_" + HybridUtils.area
|
||||
.getId() + "_" + HybridUtils.area.getWorldName());
|
||||
if (file.exists() && !file.delete()) {
|
||||
PlotSquared.log(Captions.PREFIX
|
||||
@ -1622,11 +1624,11 @@ public class PlotSquared {
|
||||
database = new MySQL(Storage.MySQL.HOST, Storage.MySQL.PORT, Storage.MySQL.DATABASE,
|
||||
Storage.MySQL.USER, Storage.MySQL.PASSWORD);
|
||||
} else if (Storage.SQLite.USE) {
|
||||
File file = MainUtil.getFile(IMP.getDirectory(), Storage.SQLite.DB + ".db");
|
||||
File file = MainUtil.getFile(platform.getDirectory(), Storage.SQLite.DB + ".db");
|
||||
database = new SQLite(file);
|
||||
} else {
|
||||
PlotSquared.log(Captions.PREFIX + "&cNo storage type is set!");
|
||||
this.IMP.shutdown(); //shutdown used instead of disable because no database is set
|
||||
this.platform.shutdown(); //shutdown used instead of disable because no database is set
|
||||
return;
|
||||
}
|
||||
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, false);
|
||||
@ -1654,9 +1656,9 @@ public class PlotSquared {
|
||||
"&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
||||
e.printStackTrace();
|
||||
PlotSquared.log("&d==== End of stacktrace ====");
|
||||
PlotSquared.log("&6Please go to the " + IMP.getPluginName()
|
||||
PlotSquared.log("&6Please go to the " + platform.getPluginName()
|
||||
+ " 'storage.yml' and configure the database correctly.");
|
||||
this.IMP.shutdown(); //shutdown used instead of disable because of database error
|
||||
this.platform.shutdown(); //shutdown used instead of disable because of database error
|
||||
}
|
||||
}
|
||||
|
||||
@ -1680,7 +1682,7 @@ public class PlotSquared {
|
||||
try {
|
||||
worlds.save(worldsFile);
|
||||
} catch (IOException e) {
|
||||
PlotSquared.debug("Failed to save " + IMP.getPluginName() + " worlds.yml");
|
||||
PlotSquared.debug("Failed to save " + platform.getPluginName() + " worlds.yml");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -1711,7 +1713,7 @@ public class PlotSquared {
|
||||
* - Translation: PlotSquared.use_THIS.yml, style.yml<br>
|
||||
*/
|
||||
public boolean setupConfigs() {
|
||||
File folder = new File(this.IMP.getDirectory(), "config");
|
||||
File folder = new File(this.platform.getDirectory(), "config");
|
||||
if (!folder.exists() && !folder.mkdirs()) {
|
||||
PlotSquared.log(Captions.PREFIX
|
||||
+ "&cFailed to create the /plugins/config folder. Please create it manually.");
|
||||
@ -1747,7 +1749,7 @@ public class PlotSquared {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Disable plugin
|
||||
this.IMP.shutdown();
|
||||
this.platform.shutdown();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -1768,7 +1770,7 @@ public class PlotSquared {
|
||||
PlotSquared.log("Failed to save settings.yml");
|
||||
}
|
||||
try {
|
||||
this.styleFile = MainUtil.getFile(IMP.getDirectory(),
|
||||
this.styleFile = MainUtil.getFile(platform.getDirectory(),
|
||||
Settings.Paths.TRANSLATIONS + File.separator + "style.yml");
|
||||
if (!this.styleFile.exists()) {
|
||||
if (!this.styleFile.getParentFile().exists()) {
|
||||
|
@ -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, @NotNull final Plot plot, @NotNull Runnable whenDone) {
|
||||
Objects.requireNonNull(PlotSquared.imp()).getBackupManager().automaticBackup(player, plot, whenDone);
|
||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().automaticBackup(player, plot, whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ public class NullBackupManager implements BackupManager {
|
||||
}
|
||||
|
||||
@Override @NotNull public Path getBackupPath() {
|
||||
return Objects.requireNonNull(PlotSquared.imp()).getDirectory().toPath();
|
||||
return Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath();
|
||||
}
|
||||
|
||||
@Override public int getBackupLimit() {
|
||||
|
@ -57,7 +57,7 @@ import java.util.concurrent.TimeUnit;
|
||||
.expireAfterAccess(3, TimeUnit.MINUTES).build();
|
||||
|
||||
public SimpleBackupManager() throws Exception {
|
||||
this.backupPath = Objects.requireNonNull(PlotSquared.imp()).getDirectory().toPath().resolve("backups");
|
||||
this.backupPath = Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath().resolve("backups");
|
||||
if (!Files.exists(backupPath)) {
|
||||
Files.createDirectory(backupPath);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class Area extends SubCommand {
|
||||
// There's only one plot in the area...
|
||||
final PlotId plotId = new PlotId(1, 1);
|
||||
final HybridPlotWorld hybridPlotWorld = new HybridPlotWorld(player.getLocation().getWorld(), args[1],
|
||||
Objects.requireNonNull(PlotSquared.imp()).getDefaultGenerator(), plotId, plotId);
|
||||
Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId);
|
||||
// Plot size is the same as the region width
|
||||
hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
|
||||
// We use a schematic generator
|
||||
@ -153,7 +153,7 @@ public class Area extends SubCommand {
|
||||
hybridPlotWorld.PLOT_HEIGHT = hybridPlotWorld.ROAD_HEIGHT = hybridPlotWorld.WALL_HEIGHT = playerSelectionMin.getBlockY();
|
||||
// No sign plz
|
||||
hybridPlotWorld.setAllowSigns(false);
|
||||
final File parentFile = MainUtil.getFile(PlotSquared.imp().getDirectory(), "schematics" + File.separator +
|
||||
final File parentFile = MainUtil.getFile(PlotSquared.platform().getDirectory(), "schematics" + File.separator +
|
||||
"GEN_ROAD_SCHEMATIC" + File.separator + hybridPlotWorld.getWorldName() + File.separator +
|
||||
hybridPlotWorld.getId());
|
||||
if (!parentFile.exists() && !parentFile.mkdirs()) {
|
||||
@ -187,8 +187,8 @@ public class Area extends SubCommand {
|
||||
|
||||
// Now the schematic is saved, which is wonderful!
|
||||
PlotAreaBuilder singleBuilder = PlotAreaBuilder.ofPlotArea(hybridPlotWorld)
|
||||
.plotManager(PlotSquared.imp().getPluginName())
|
||||
.generatorName(PlotSquared.imp().getPluginName())
|
||||
.plotManager(PlotSquared.platform().getPluginName())
|
||||
.generatorName(PlotSquared.platform().getPluginName())
|
||||
.maximumId(plotId)
|
||||
.minimumId(plotId);
|
||||
Runnable singleRun = () -> {
|
||||
@ -282,8 +282,8 @@ public class Area extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
PlotAreaBuilder builder = PlotAreaBuilder.ofPlotArea(area)
|
||||
.plotManager(PlotSquared.imp().getPluginName())
|
||||
.generatorName(PlotSquared.imp().getPluginName())
|
||||
.plotManager(PlotSquared.platform().getPluginName())
|
||||
.generatorName(PlotSquared.platform().getPluginName())
|
||||
.minimumId(new PlotId(1, 1))
|
||||
.maximumId(new PlotId(numX, numZ));
|
||||
final String path =
|
||||
@ -339,7 +339,7 @@ public class Area extends SubCommand {
|
||||
PlotAreaBuilder builder = new PlotAreaBuilder();
|
||||
builder.worldName(split[0]);
|
||||
final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id,
|
||||
PlotSquared.get().IMP.getDefaultGenerator(), null, null);
|
||||
PlotSquared.platform().getDefaultGenerator(), null, null);
|
||||
PlotArea other = PlotSquared.get().getPlotArea(pa.getWorldName(), id);
|
||||
if (other != null && Objects.equals(pa.getId(), other.getId())) {
|
||||
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
||||
@ -428,8 +428,8 @@ public class Area extends SubCommand {
|
||||
PlotSquared.get().worlds.getConfigurationSection(path);
|
||||
pa.saveConfiguration(section);
|
||||
pa.loadConfiguration(section);
|
||||
builder.plotManager(PlotSquared.imp().getPluginName());
|
||||
builder.generatorName(PlotSquared.imp().getPluginName());
|
||||
builder.plotManager(PlotSquared.platform().getPluginName());
|
||||
builder.generatorName(PlotSquared.platform().getPluginName());
|
||||
String world = SetupUtils.manager.setupWorld(builder);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
Captions.SETUP_FINISHED.send(player);
|
||||
@ -661,7 +661,7 @@ public class Area extends SubCommand {
|
||||
case "remove":
|
||||
MainUtil.sendMessage(player,
|
||||
"$1World creation settings may be stored in multiple locations:"
|
||||
+ "\n$3 - $2Bukkit bukkit.yml" + "\n$3 - $2" + PlotSquared.imp()
|
||||
+ "\n$3 - $2Bukkit bukkit.yml" + "\n$3 - $2" + PlotSquared.platform()
|
||||
.getPluginName() + " settings.yml"
|
||||
+ "\n$3 - $2Multiverse worlds.yml (or any world management plugin)"
|
||||
+ "\n$1Stop the server and delete it from these locations.");
|
||||
|
@ -91,7 +91,7 @@ public final class Backup extends Command {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot != null) {
|
||||
final BackupProfile backupProfile =
|
||||
Objects.requireNonNull(PlotSquared.imp()).getBackupManager().getProfile(plot);
|
||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(plot);
|
||||
if (backupProfile instanceof PlayerBackupProfile) {
|
||||
final CompletableFuture<List<com.plotsquared.core.backup.Backup>> backupList =
|
||||
backupProfile.listBackups();
|
||||
@ -136,7 +136,7 @@ public final class Backup extends Command {
|
||||
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
|
||||
} else {
|
||||
final BackupProfile backupProfile =
|
||||
Objects.requireNonNull(PlotSquared.imp()).getBackupManager().getProfile(plot);
|
||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(plot);
|
||||
if (backupProfile instanceof NullBackupProfile) {
|
||||
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
|
||||
Captions.GENERIC_OTHER.getTranslated());
|
||||
@ -176,7 +176,7 @@ public final class Backup extends Command {
|
||||
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
|
||||
} else {
|
||||
final BackupProfile backupProfile =
|
||||
Objects.requireNonNull(PlotSquared.imp()).getBackupManager().getProfile(plot);
|
||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(plot);
|
||||
if (backupProfile instanceof NullBackupProfile) {
|
||||
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
|
||||
Captions.GENERIC_OTHER.getTranslated());
|
||||
@ -238,7 +238,7 @@ public final class Backup extends Command {
|
||||
return;
|
||||
}
|
||||
final BackupProfile backupProfile =
|
||||
Objects.requireNonNull(PlotSquared.imp()).getBackupManager().getProfile(plot);
|
||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(plot);
|
||||
if (backupProfile instanceof NullBackupProfile) {
|
||||
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
|
||||
Captions.GENERIC_OTHER.getTranslated());
|
||||
|
@ -82,9 +82,9 @@ public class Buy extends Command {
|
||||
confirm.run(this, () -> {
|
||||
Captions.REMOVED_BALANCE.send(player, price);
|
||||
|
||||
EconHandler.getEconHandler().depositMoney(PlotSquared.imp().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
|
||||
EconHandler.getEconHandler().depositMoney(PlotSquared.platform().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
|
||||
|
||||
PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs());
|
||||
PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs());
|
||||
if (owner != null) {
|
||||
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ public class Cluster extends SubCommand {
|
||||
DBFunc.setInvited(cluster, uuid);
|
||||
|
||||
final PlotPlayer otherPlayer =
|
||||
PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if (otherPlayer != null) {
|
||||
MainUtil.sendMessage(otherPlayer, Captions.CLUSTER_INVITED,
|
||||
cluster.getName());
|
||||
@ -448,7 +448,7 @@ public class Cluster extends SubCommand {
|
||||
DBFunc.removeInvited(cluster, uuid);
|
||||
|
||||
final PlotPlayer player2 =
|
||||
PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if (player2 != null) {
|
||||
MainUtil.sendMessage(player2, Captions.CLUSTER_REMOVED,
|
||||
cluster.getName());
|
||||
|
@ -96,7 +96,7 @@ public class Comment extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (final PlotPlayer pp : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
||||
for (final PlotPlayer pp : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||
if (pp.getAttribute("chatspy")) {
|
||||
MainUtil.sendMessage(pp, "/plot comment " + StringMan.join(args, " "));
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class DatabaseCommand extends SubCommand {
|
||||
.sendMessage(player, "/plot database import <sqlite file> [prefix]");
|
||||
return false;
|
||||
}
|
||||
File file = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
|
||||
File file = MainUtil.getFile(PlotSquared.platform().getDirectory(),
|
||||
args[1].endsWith(".db") ? args[1] : args[1] + ".db");
|
||||
if (!file.exists()) {
|
||||
MainUtil.sendMessage(player, "&6Database does not exist: " + file);
|
||||
@ -127,11 +127,11 @@ public class DatabaseCommand extends SubCommand {
|
||||
PlotId newId = newPlot.getId();
|
||||
PlotId id = plot.getId();
|
||||
File worldFile =
|
||||
new File(PlotSquared.imp().getWorldContainer(),
|
||||
new File(PlotSquared.platform().getWorldContainer(),
|
||||
id.toCommaSeparatedString());
|
||||
if (worldFile.exists()) {
|
||||
File newFile =
|
||||
new File(PlotSquared.imp().getWorldContainer(),
|
||||
new File(PlotSquared.platform().getWorldContainer(),
|
||||
newId.toCommaSeparatedString());
|
||||
worldFile.renameTo(newFile);
|
||||
}
|
||||
@ -179,7 +179,7 @@ public class DatabaseCommand extends SubCommand {
|
||||
return MainUtil.sendMessage(player, "/plot database sqlite [file]");
|
||||
}
|
||||
File sqliteFile =
|
||||
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), args[1] + ".db");
|
||||
MainUtil.getFile(PlotSquared.platform().getDirectory(), args[1] + ".db");
|
||||
implementation = new SQLite(sqliteFile);
|
||||
break;
|
||||
default:
|
||||
|
@ -89,12 +89,12 @@ public class DebugExec extends SubCommand {
|
||||
/*
|
||||
try {
|
||||
if (PlotSquared.get() != null) {
|
||||
File file = new File(PlotSquared.get().IMP.getDirectory(),
|
||||
File file = new File(PlotSquared.imp().getDirectory(),
|
||||
Settings.Paths.SCRIPTS + File.separator + "start.js");
|
||||
if (file.exists()) {
|
||||
init();
|
||||
String script = StringMan.join(Files.readLines(new File(new File(
|
||||
PlotSquared.get().IMP.getDirectory() + File.separator
|
||||
PlotSquared.imp().getDirectory() + File.separator
|
||||
+ Settings.Paths.SCRIPTS), "start.js"), StandardCharsets.UTF_8),
|
||||
System.getProperty("line.separator"));
|
||||
this.scope.put("THIS", this);
|
||||
@ -169,7 +169,7 @@ public class DebugExec extends SubCommand {
|
||||
this.scope.put("EconHandler", EconHandler.getEconHandler());
|
||||
this.scope.put("DBFunc", DBFunc.dbManager);
|
||||
this.scope.put("HybridUtils", HybridUtils.manager);
|
||||
this.scope.put("IMP", PlotSquared.get().IMP);
|
||||
this.scope.put("IMP", PlotSquared.platform());
|
||||
this.scope.put("MainCommand", MainCommand.getInstance());
|
||||
|
||||
// enums
|
||||
@ -306,7 +306,7 @@ public class DebugExec extends SubCommand {
|
||||
case "addcmd":
|
||||
try {
|
||||
final String cmd = StringMan.join(Files.readLines(MainUtil.getFile(new File(
|
||||
PlotSquared.get().IMP.getDirectory() + File.separator
|
||||
PlotSquared.platform().getDirectory() + File.separator
|
||||
+ Settings.Paths.SCRIPTS), args[1]), StandardCharsets.UTF_8),
|
||||
System.getProperty("line.separator"));
|
||||
new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null,
|
||||
@ -338,7 +338,7 @@ public class DebugExec extends SubCommand {
|
||||
case "run":
|
||||
try {
|
||||
script = StringMan.join(Files.readLines(MainUtil.getFile(new File(
|
||||
PlotSquared.get().IMP.getDirectory() + File.separator
|
||||
PlotSquared.platform().getDirectory() + File.separator
|
||||
+ Settings.Paths.SCRIPTS), args[1]), StandardCharsets.UTF_8),
|
||||
System.getProperty("line.separator"));
|
||||
if (args.length > 2) {
|
||||
@ -354,7 +354,7 @@ public class DebugExec extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "list-scripts":
|
||||
String path = PlotSquared.get().IMP.getDirectory() + File.separator
|
||||
String path = PlotSquared.platform().getDirectory() + File.separator
|
||||
+ Settings.Paths.SCRIPTS;
|
||||
File folder = new File(path);
|
||||
File[] filesArray = folder.listFiles();
|
||||
|
@ -63,7 +63,7 @@ public class DebugImportWorlds extends Command {
|
||||
}
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) pam).getArea();
|
||||
PlotId id = new PlotId(0, 0);
|
||||
File container = PlotSquared.imp().getWorldContainer();
|
||||
File container = PlotSquared.platform().getWorldContainer();
|
||||
if (container.equals(new File("."))) {
|
||||
player.sendMessage(
|
||||
"World container must be configured to be a separate directory to your base files!");
|
||||
|
@ -87,13 +87,13 @@ 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.get().IMP.getServerImplementation())
|
||||
b.append("Server Version: ").append(PlotSquared.platform().getServerImplementation())
|
||||
.append("\n");
|
||||
b.append("online_mode: ").append(!Settings.UUID.OFFLINE).append(';')
|
||||
.append(!Settings.UUID.OFFLINE).append('\n');
|
||||
b.append("Plugins:");
|
||||
for (Map.Entry<Map.Entry<String, String>, Boolean> pluginInfo : PlotSquared
|
||||
.get().IMP.getPluginIds()) {
|
||||
.platform().getPluginIds()) {
|
||||
Map.Entry<String, String> nameVersion = pluginInfo.getKey();
|
||||
String name = nameVersion.getKey();
|
||||
String version = nameVersion.getValue();
|
||||
@ -129,7 +129,7 @@ public class DebugPaste extends SubCommand {
|
||||
|
||||
try {
|
||||
final File logFile =
|
||||
new File(PlotSquared.get().IMP.getDirectory(), "../../logs/latest.log");
|
||||
new File(PlotSquared.platform().getDirectory(), "../../logs/latest.log");
|
||||
if (Files.size(logFile.toPath()) > 14_000_000) {
|
||||
throw new IOException("Too big...");
|
||||
}
|
||||
@ -161,7 +161,7 @@ public class DebugPaste extends SubCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
final File MultiverseWorlds = new File(PlotSquared.get().IMP.getDirectory(),
|
||||
final File MultiverseWorlds = new File(PlotSquared.platform().getDirectory(),
|
||||
"../Multiverse-Core/worlds.yml");
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("MultiverseCore/worlds.yml",
|
||||
readFile(MultiverseWorlds)));
|
||||
|
@ -96,7 +96,7 @@ public class Deny extends SubCommand {
|
||||
plot.addDenied(uuid);
|
||||
PlotSquared.get().getEventDispatcher().callDenied(player, plot, uuid, true);
|
||||
if (!uuid.equals(DBFunc.EVERYONE)) {
|
||||
handleKick(PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid), plot);
|
||||
handleKick(PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid), plot);
|
||||
} else {
|
||||
for (PlotPlayer plotPlayer : plot.getPlayersInPlot()) {
|
||||
// Ignore plot-owners
|
||||
|
@ -99,7 +99,7 @@ public class Grant extends Command {
|
||||
String key = "grantedPlots";
|
||||
byte[] rawData = Ints.toByteArray(amount);
|
||||
|
||||
PlotPlayer online = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
PlotPlayer online = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if (online != null) {
|
||||
online.setPersistentMeta(key, rawData);
|
||||
} else {
|
||||
|
@ -86,7 +86,7 @@ public class Kick extends SubCommand {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
PlotPlayer<?> pp = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
PlotPlayer<?> pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if (pp != null) {
|
||||
players.add(pp);
|
||||
}
|
||||
|
@ -383,7 +383,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.imp().getPlayerManager().getPlayerIfExists(uuidMapping.getUuid());
|
||||
PlotPlayer pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuidMapping.getUuid());
|
||||
if (pp != null) {
|
||||
message = message.text(prefix).color("$4").text(uuidMapping.getUsername()).color("$1")
|
||||
.tooltip(new PlotMessage("Online").color("$4"));
|
||||
@ -415,7 +415,7 @@ public class ListCmd extends SubCommand {
|
||||
completions.add("shared");
|
||||
}
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_WORLD)) {
|
||||
completions.addAll(PlotSquared.imp().getWorldManager().getWorlds());
|
||||
completions.addAll(PlotSquared.platform().getWorldManager().getWorlds());
|
||||
}
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_TOP)) {
|
||||
completions.add("top");
|
||||
|
@ -212,7 +212,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.imp().getPlayerManager().getPlayerIfExists(owner);
|
||||
final PlotPlayer accepter = PlotSquared.platform().getPlayerManager().getPlayerIfExists(owner);
|
||||
if (!force && accepter == null) {
|
||||
continue;
|
||||
}
|
||||
@ -221,7 +221,7 @@ public class Merge extends SubCommand {
|
||||
Runnable run = () -> {
|
||||
MainUtil.sendMessage(accepter, Captions.MERGE_ACCEPTED);
|
||||
plot.autoMerge(dir, maxSize - size, owner, terrain);
|
||||
PlotPlayer plotPlayer = PlotSquared.imp().getPlayerManager().getPlayerIfExists(player.getUUID());
|
||||
PlotPlayer plotPlayer = PlotSquared.platform().getPlayerManager().getPlayerIfExists(player.getUUID());
|
||||
if (plotPlayer == null) {
|
||||
sendMessage(accepter, Captions.MERGE_NOT_VALID);
|
||||
return;
|
||||
|
@ -95,7 +95,7 @@ public class Owner extends SetCommand {
|
||||
MainUtil.sendMessage(player, Captions.SET_OWNER);
|
||||
return;
|
||||
}
|
||||
final PlotPlayer other = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
final PlotPlayer other = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if (plot.isOwner(uuid)) {
|
||||
Captions.ALREADY_OWNER.send(player, MainUtil.getName(uuid));
|
||||
return;
|
||||
|
@ -42,7 +42,7 @@ public class PluginCmd extends SubCommand {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
TaskManager.IMP.taskAsync(() -> {
|
||||
MainUtil.sendMessage(player, String.format(
|
||||
"$2>> $1&l" + PlotSquared.imp().getPluginName() + " $2($1Version$2: $1%s$2)",
|
||||
"$2>> $1&l" + PlotSquared.platform().getPluginName() + " $2($1Version$2: $1%s$2)",
|
||||
PlotSquared.get().getVersion()));
|
||||
MainUtil.sendMessage(player,
|
||||
"$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21 $2& $1NotMyFault $2& $1SirYwell");
|
||||
|
@ -52,7 +52,7 @@ public class Setup extends SubCommand {
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append("&6What generator do you want?");
|
||||
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
|
||||
if (entry.getKey().equals(PlotSquared.imp().getPluginName())) {
|
||||
if (entry.getKey().equals(PlotSquared.platform().getPluginName())) {
|
||||
message.append("\n&8 - &2").append(entry.getKey()).append(" (Default Generator)");
|
||||
} else if (entry.getValue().isFull()) {
|
||||
message.append("\n&8 - &7").append(entry.getKey()).append(" (Plot Generator)");
|
||||
|
@ -64,11 +64,11 @@ public class Template extends SubCommand {
|
||||
public static boolean extractAllFiles(String world, String template) {
|
||||
try {
|
||||
File folder =
|
||||
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), Settings.Paths.TEMPLATES);
|
||||
MainUtil.getFile(PlotSquared.platform().getDirectory(), Settings.Paths.TEMPLATES);
|
||||
if (!folder.exists()) {
|
||||
return false;
|
||||
}
|
||||
File output = PlotSquared.get().IMP.getDirectory();
|
||||
File output = PlotSquared.platform().getDirectory();
|
||||
if (!output.exists()) {
|
||||
output.mkdirs();
|
||||
}
|
||||
@ -120,7 +120,7 @@ public class Template extends SubCommand {
|
||||
|
||||
public static void zipAll(String world, Set<FileBytes> files) throws IOException {
|
||||
File output =
|
||||
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), Settings.Paths.TEMPLATES);
|
||||
MainUtil.getFile(PlotSquared.platform().getDirectory(), Settings.Paths.TEMPLATES);
|
||||
output.mkdirs();
|
||||
try (FileOutputStream fos = new FileOutputStream(
|
||||
output + File.separator + world + ".template");
|
||||
@ -169,7 +169,7 @@ public class Template extends SubCommand {
|
||||
.sendMessage(player, "&cInvalid template file: " + args[2] + ".template");
|
||||
return false;
|
||||
}
|
||||
File worldFile = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
|
||||
File worldFile = MainUtil.getFile(PlotSquared.platform().getDirectory(),
|
||||
Settings.Paths.TEMPLATES + File.separator + "tmp-data.yml");
|
||||
YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile);
|
||||
PlotSquared.get().worlds.set("worlds." + world, worldConfig.get(""));
|
||||
@ -180,7 +180,7 @@ public class Template extends SubCommand {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String manager =
|
||||
worldConfig.getString("generator.plugin", PlotSquared.imp().getPluginName());
|
||||
worldConfig.getString("generator.plugin", PlotSquared.platform().getPluginName());
|
||||
String generator = worldConfig.getString("generator.init", manager);
|
||||
PlotAreaBuilder builder = new PlotAreaBuilder()
|
||||
.plotAreaType(MainUtil.getType(worldConfig))
|
||||
|
@ -73,7 +73,7 @@ public class Trim extends SubCommand {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override public void run() {
|
||||
String directory = world + File.separator + "region";
|
||||
File folder = new File(PlotSquared.get().IMP.getWorldContainer(), directory);
|
||||
File folder = new File(PlotSquared.platform().getWorldContainer(), directory);
|
||||
File[] regionFiles = folder.listFiles();
|
||||
for (File file : regionFiles) {
|
||||
String name = file.getName();
|
||||
|
@ -61,7 +61,7 @@ public class ComponentPresetManager {
|
||||
private final String guiName;
|
||||
|
||||
public ComponentPresetManager() {
|
||||
final File file = new File(Objects.requireNonNull(PlotSquared.imp()).getDirectory(), "components.yml");
|
||||
final File file = new File(Objects.requireNonNull(PlotSquared.platform()).getDirectory(), "components.yml");
|
||||
if (!file.exists()) {
|
||||
boolean created = false;
|
||||
try {
|
||||
|
@ -56,8 +56,8 @@ public class SQLite extends Database {
|
||||
if (checkConnection()) {
|
||||
return this.connection;
|
||||
}
|
||||
if (!PlotSquared.get().IMP.getDirectory().exists()) {
|
||||
PlotSquared.get().IMP.getDirectory().mkdirs();
|
||||
if (!PlotSquared.platform().getDirectory().exists()) {
|
||||
PlotSquared.platform().getDirectory().mkdirs();
|
||||
}
|
||||
File file = new File(this.dbLocation);
|
||||
if (!file.exists()) {
|
||||
|
@ -41,7 +41,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class HybridGen extends IndependentPlotGenerator {
|
||||
|
||||
@Override public String getName() {
|
||||
return PlotSquared.imp().getPluginName();
|
||||
return PlotSquared.platform().getPluginName();
|
||||
}
|
||||
|
||||
private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX,
|
||||
|
@ -74,7 +74,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
.getWorldName() + File.separator;
|
||||
try {
|
||||
File sideRoad =
|
||||
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "sideroad.schem");
|
||||
MainUtil.getFile(PlotSquared.platform().getDirectory(), dir + "sideroad.schem");
|
||||
String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator
|
||||
+ "__TEMP_DIR__" + File.separator;
|
||||
if (sideRoad.exists()) {
|
||||
@ -82,12 +82,12 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Files.readAllBytes(sideRoad.toPath())));
|
||||
}
|
||||
File intersection =
|
||||
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "intersection.schem");
|
||||
MainUtil.getFile(PlotSquared.platform().getDirectory(), dir + "intersection.schem");
|
||||
if (intersection.exists()) {
|
||||
files.add(new FileBytes(newDir + "intersection.schem",
|
||||
Files.readAllBytes(intersection.toPath())));
|
||||
}
|
||||
File plot = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "plot.schem");
|
||||
File plot = MainUtil.getFile(PlotSquared.platform().getDirectory(), dir + "plot.schem");
|
||||
if (plot.exists()) {
|
||||
files.add(new FileBytes(newDir + "plot.schem", Files.readAllBytes(plot.toPath())));
|
||||
}
|
||||
|
@ -200,9 +200,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
|
||||
// Try to determine root. This means that plot areas can have separate schematic
|
||||
// directories
|
||||
if (!(root = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" +
|
||||
if (!(root = MainUtil.getFile(PlotSquared.platform().getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" +
|
||||
this.getWorldName() + "/" + this.getId())).exists()) {
|
||||
root = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
|
||||
root = MainUtil.getFile(PlotSquared.platform().getDirectory(),
|
||||
"schematics/GEN_ROAD_SCHEMATIC/" + this.getWorldName());
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.SetupObject;
|
||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||
import com.plotsquared.core.setup.SetupProcess;
|
||||
|
||||
/**
|
||||
* This class allows for implementation independent world generation.
|
||||
@ -104,7 +103,7 @@ public abstract class IndependentPlotGenerator {
|
||||
* @return
|
||||
*/
|
||||
public <T> GeneratorWrapper<T> specify(String world) {
|
||||
return (GeneratorWrapper<T>) PlotSquared.get().IMP.wrapPlotGenerator(world, this);
|
||||
return (GeneratorWrapper<T>) PlotSquared.platform().wrapPlotGenerator(world, this);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
|
@ -160,7 +160,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.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
final PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if (owner != null && !owner.getUUID().equals(player.getUUID())) {
|
||||
MainUtil.sendMessage(owner, Captions.NOTIFY_ENTER.getTranslated()
|
||||
.replace("%player", player.getName())
|
||||
@ -336,7 +336,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.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
final PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if ((owner != null) && !owner.getUUID().equals(player.getUUID())) {
|
||||
MainUtil.sendMessage(owner, Captions.NOTIFY_LEAVE.getTranslated()
|
||||
.replace("%player", player.getName())
|
||||
|
@ -68,7 +68,7 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
||||
}
|
||||
|
||||
@Override public Actor toActor() {
|
||||
return PlotSquared.get().IMP.getConsole();
|
||||
return PlotSquared.platform().getConsole();
|
||||
}
|
||||
|
||||
@Override public Actor getPlatformPlayer() {
|
||||
|
@ -129,7 +129,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
* @return Wrapped player
|
||||
*/
|
||||
public static PlotPlayer<?> wrap(Object player) {
|
||||
return PlotSquared.get().IMP.wrapPlayer(player);
|
||||
return PlotSquared.platform().wrapPlayer(player);
|
||||
}
|
||||
|
||||
public abstract Actor toActor();
|
||||
@ -588,8 +588,8 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
if (ExpireManager.IMP != null) {
|
||||
ExpireManager.IMP.storeDate(getUUID(), System.currentTimeMillis());
|
||||
}
|
||||
PlotSquared.imp().getPlayerManager().removePlayer(this);
|
||||
PlotSquared.get().IMP.unregister(this);
|
||||
PlotSquared.platform().getPlayerManager().removePlayer(this);
|
||||
PlotSquared.platform().unregister(this);
|
||||
|
||||
debugModeEnabled.remove(this);
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ public class Plot {
|
||||
*/
|
||||
public List<PlotPlayer<?>> getPlayersInPlot() {
|
||||
final List<PlotPlayer<?>> players = new ArrayList<>();
|
||||
for (final PlotPlayer<?> player : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
||||
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||
if (this.equals(player.getCurrentPlot())) {
|
||||
players.add(player);
|
||||
}
|
||||
@ -1330,7 +1330,7 @@ public class Plot {
|
||||
|
||||
if (Settings.Backup.DELETE_ON_UNCLAIM) {
|
||||
// Destroy all backups when the plot is unclaimed
|
||||
Objects.requireNonNull(PlotSquared.imp()).getBackupManager().getProfile(current)
|
||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(current)
|
||||
.destroy();
|
||||
}
|
||||
|
||||
@ -3039,11 +3039,11 @@ public class Plot {
|
||||
return false;
|
||||
}
|
||||
if (!isMerged()) {
|
||||
return PlotSquared.imp().getPlayerManager()
|
||||
return PlotSquared.platform().getPlayerManager()
|
||||
.getPlayerIfExists(Objects.requireNonNull(this.getOwnerAbs())) != null;
|
||||
}
|
||||
for (final Plot current : getConnectedPlots()) {
|
||||
if (current.hasOwner() && PlotSquared.imp().getPlayerManager()
|
||||
if (current.hasOwner() && PlotSquared.platform().getPlayerManager()
|
||||
.getPlayerIfExists(Objects.requireNonNull(current.getOwnerAbs())) != null) {
|
||||
return true;
|
||||
}
|
||||
|
@ -409,13 +409,13 @@ public class ExpireManager {
|
||||
}
|
||||
}
|
||||
for (UUID helper : plot.getTrusted()) {
|
||||
PlotPlayer player = PlotSquared.imp().getPlayerManager().getPlayerIfExists(helper);
|
||||
PlotPlayer player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(helper);
|
||||
if (player != null) {
|
||||
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
|
||||
}
|
||||
}
|
||||
for (UUID helper : plot.getMembers()) {
|
||||
PlotPlayer player = PlotSquared.imp().getPlayerManager().getPlayerIfExists(helper);
|
||||
PlotPlayer player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(helper);
|
||||
if (player != null) {
|
||||
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
|
||||
}
|
||||
@ -438,12 +438,12 @@ public class ExpireManager {
|
||||
}
|
||||
|
||||
public long getAge(UUID uuid) {
|
||||
if (PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid) != null) {
|
||||
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid) != null) {
|
||||
return 0;
|
||||
}
|
||||
Long last = this.dates_cache.get(uuid);
|
||||
if (last == null) {
|
||||
OfflinePlotPlayer opp = PlotSquared.imp().getPlayerManager().getOfflinePlayer(uuid);
|
||||
OfflinePlotPlayer opp = PlotSquared.platform().getPlayerManager().getOfflinePlayer(uuid);
|
||||
if (opp != null && (last = opp.getLastPlayed()) != 0) {
|
||||
this.dates_cache.put(uuid, last);
|
||||
} else {
|
||||
@ -458,7 +458,7 @@ public class ExpireManager {
|
||||
|
||||
public long getAge(Plot plot) {
|
||||
if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.getOwner())
|
||||
|| PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwner()) != null || plot.getRunning() > 0) {
|
||||
|| PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwner()) != null || plot.getRunning() > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ public class PlotMessage {
|
||||
reset(ChatManager.manager);
|
||||
} catch (Throwable e) {
|
||||
PlotSquared.debug(
|
||||
PlotSquared.imp().getPluginName() + " doesn't support fancy chat for " + PlotSquared
|
||||
.get().IMP.getServerVersion());
|
||||
PlotSquared.platform().getPluginName() + " doesn't support fancy chat for " + PlotSquared
|
||||
.platform().getServerVersion());
|
||||
ChatManager.manager = new PlainChatManager();
|
||||
reset(ChatManager.manager);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||
.settingsNodesWrapper(new SettingsNodesWrapper(new ConfigurationNode[0], null))
|
||||
.worldName(worldName);
|
||||
|
||||
File container = PlotSquared.imp().getWorldContainer();
|
||||
File container = PlotSquared.platform().getWorldContainer();
|
||||
File destination = new File(container, worldName);
|
||||
|
||||
{// convert old
|
||||
|
@ -63,7 +63,7 @@ public class SinglePlotManager extends PlotManager {
|
||||
@Override public boolean clearPlot(Plot plot, final Runnable whenDone) {
|
||||
SetupUtils.manager.unload(plot.getWorldName(), false);
|
||||
final File worldFolder =
|
||||
new File(PlotSquared.get().IMP.getWorldContainer(), plot.getWorldName());
|
||||
new File(PlotSquared.platform().getWorldContainer(), plot.getWorldName());
|
||||
TaskManager.IMP.taskAsync(() -> {
|
||||
MainUtil.deleteDirectory(worldFolder);
|
||||
if (whenDone != null) {
|
||||
|
@ -123,7 +123,7 @@ public abstract class LocalBlockQueue {
|
||||
fixChunkLighting(x, z);
|
||||
BlockVector2 loc = BlockVector2.at(x, z);
|
||||
|
||||
for (final PlotPlayer pp : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
||||
for (final PlotPlayer pp : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||
Location pLoc = pp.getLocation();
|
||||
if (!StringMan.isEqual(getWorld(), pLoc.getWorld()) || !pLoc.getBlockVector2()
|
||||
.equals(loc)) {
|
||||
|
@ -59,8 +59,8 @@ public enum CommonSetupSteps implements SetupStep {
|
||||
String prefix = "\n&8 - &7";
|
||||
sendMessage(plotPlayer, Captions.SETUP_WORLD_GENERATOR_ERROR + prefix + StringMan
|
||||
.join(SetupUtils.generators.keySet(), prefix)
|
||||
.replaceAll(PlotSquared.imp().getPluginName(),
|
||||
"&2" + PlotSquared.imp().getPluginName()));
|
||||
.replaceAll(PlotSquared.platform().getPluginName(),
|
||||
"&2" + PlotSquared.platform().getPluginName()));
|
||||
return this; // invalid input -> same setup step
|
||||
}
|
||||
builder.generatorName(arg);
|
||||
@ -72,7 +72,7 @@ public enum CommonSetupSteps implements SetupStep {
|
||||
}
|
||||
|
||||
@Nullable @Override public String getDefaultValue() {
|
||||
return PlotSquared.imp().getPluginName();
|
||||
return PlotSquared.platform().getPluginName();
|
||||
}
|
||||
},
|
||||
CHOOSE_PLOT_AREA_TYPE(PlotAreaType.class, Captions.SETUP_WORLD_TYPE) {
|
||||
@ -110,7 +110,7 @@ public enum CommonSetupSteps implements SetupStep {
|
||||
SetupUtils.generators.get(builder.plotManager()).getPlotGenerator()
|
||||
.processAreaSetup(builder);
|
||||
} else {
|
||||
builder.plotManager(PlotSquared.imp().getPluginName());
|
||||
builder.plotManager(PlotSquared.platform().getPluginName());
|
||||
MainUtil.sendMessage(plotPlayer, Captions.SETUP_WRONG_GENERATOR);
|
||||
builder.settingsNodesWrapper(CommonSetupSteps.wrap(builder.plotManager()));
|
||||
// TODO why is processSetup not called here?
|
||||
|
@ -56,7 +56,7 @@ public class PlotAreaBuilder {
|
||||
.plotAreaType(area.getType())
|
||||
.terrainType(area.getTerrain())
|
||||
.generatorName(area.getGenerator().getName())
|
||||
.plotManager(PlotSquared.imp().getPluginName())
|
||||
.plotManager(PlotSquared.platform().getPluginName())
|
||||
.minimumId(area.getMin())
|
||||
.maximumId(area.getMax())
|
||||
.settingsNodesWrapper(new SettingsNodesWrapper(area.getSettingNodes(), null));
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.util;
|
||||
|
||||
import com.plotsquared.core.IPlotMain;
|
||||
import com.plotsquared.core.PlotPlatform;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.player.ConsolePlayer;
|
||||
import com.plotsquared.core.player.OfflinePlotPlayer;
|
||||
@ -36,27 +36,27 @@ public abstract class EconHandler {
|
||||
|
||||
/**
|
||||
* @deprecated This will be removed in the future,
|
||||
* call {@link IPlotMain#getEconomyHandler()} instead.
|
||||
* call {@link PlotPlatform#getEconomyHandler()} instead.
|
||||
*/
|
||||
@Deprecated @Nullable public static EconHandler manager;
|
||||
|
||||
/**
|
||||
* Initialize the economy handler using {@link IPlotMain#getEconomyHandler()}
|
||||
* @deprecated Call {@link #init} instead or use {@link IPlotMain#getEconomyHandler()}
|
||||
* Initialize the economy handler using {@link PlotPlatform#getEconomyHandler()}
|
||||
* @deprecated Call {@link #init} instead or use {@link PlotPlatform#getEconomyHandler()}
|
||||
* which does this already.
|
||||
*/
|
||||
@Deprecated public static void initializeEconHandler() {
|
||||
manager = PlotSquared.get().IMP.getEconomyHandler();
|
||||
manager = PlotSquared.platform().getEconomyHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the econ handler instance, if one exists
|
||||
*
|
||||
* @return Economy handler instance
|
||||
* @deprecated Call {@link IPlotMain#getEconomyHandler()} instead
|
||||
* @deprecated Call {@link PlotPlatform#getEconomyHandler()} instead
|
||||
*/
|
||||
@Deprecated @Nullable public static EconHandler getEconHandler() {
|
||||
manager = PlotSquared.get().IMP.getEconomyHandler();
|
||||
manager = PlotSquared.platform().getEconomyHandler();
|
||||
return manager;
|
||||
}
|
||||
|
||||
|
@ -969,7 +969,7 @@ public class MainUtil {
|
||||
|
||||
public static void getPersistentMeta(UUID uuid, final String key,
|
||||
final RunnableVal<byte[]> result) {
|
||||
PlotPlayer player = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
PlotPlayer player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if (player != null) {
|
||||
result.run(player.getPersistentMeta(key));
|
||||
} else {
|
||||
|
@ -107,7 +107,7 @@ public abstract class RegionManager {
|
||||
|
||||
public Set<BlockVector2> getChunkChunks(String world) {
|
||||
File folder =
|
||||
new File(PlotSquared.get().IMP.getWorldContainer(), world + File.separator + "region");
|
||||
new File(PlotSquared.platform().getWorldContainer(), world + File.separator + "region");
|
||||
File[] regionFiles = folder.listFiles();
|
||||
if (regionFiles == null) {
|
||||
throw new RuntimeException(
|
||||
@ -141,7 +141,7 @@ public abstract class RegionManager {
|
||||
String directory =
|
||||
world + File.separator + "region" + File.separator + "r." + loc.getX() + "."
|
||||
+ loc.getZ() + ".mca";
|
||||
File file = new File(PlotSquared.get().IMP.getWorldContainer(), directory);
|
||||
File file = new File(PlotSquared.platform().getWorldContainer(), directory);
|
||||
PlotSquared.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
|
@ -314,7 +314,7 @@ public abstract class SchematicHandler {
|
||||
*/
|
||||
public Schematic getSchematic(String name) throws UnsupportedFormatException {
|
||||
File parent =
|
||||
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), Settings.Paths.SCHEMATICS);
|
||||
MainUtil.getFile(PlotSquared.platform().getDirectory(), Settings.Paths.SCHEMATICS);
|
||||
if (!parent.exists()) {
|
||||
if (!parent.mkdir()) {
|
||||
throw new RuntimeException("Could not create schematic parent directory");
|
||||
@ -323,10 +323,10 @@ public abstract class SchematicHandler {
|
||||
if (!name.endsWith(".schem") && !name.endsWith(".schematic")) {
|
||||
name = name + ".schem";
|
||||
}
|
||||
File file = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
|
||||
File file = MainUtil.getFile(PlotSquared.platform().getDirectory(),
|
||||
Settings.Paths.SCHEMATICS + File.separator + name);
|
||||
if (!file.exists()) {
|
||||
file = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
|
||||
file = MainUtil.getFile(PlotSquared.platform().getDirectory(),
|
||||
Settings.Paths.SCHEMATICS + File.separator + name);
|
||||
}
|
||||
return getSchematic(file);
|
||||
@ -339,7 +339,7 @@ public abstract class SchematicHandler {
|
||||
*/
|
||||
public Collection<String> getSchematicNames() {
|
||||
final File parent =
|
||||
MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), Settings.Paths.SCHEMATICS);
|
||||
MainUtil.getFile(PlotSquared.platform().getDirectory(), Settings.Paths.SCHEMATICS);
|
||||
final List<String> names = new ArrayList<>();
|
||||
if (parent.exists()) {
|
||||
final String[] rawNames =
|
||||
@ -467,7 +467,7 @@ public abstract class SchematicHandler {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
File tmp = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), path);
|
||||
File tmp = MainUtil.getFile(PlotSquared.platform().getDirectory(), path);
|
||||
tmp.getParentFile().mkdirs();
|
||||
try (NBTOutputStream nbtStream = new NBTOutputStream(
|
||||
new GZIPOutputStream(new FileOutputStream(tmp)))) {
|
||||
|
@ -161,7 +161,7 @@ public class TabCompletions {
|
||||
cachedCompletionValues.put(cacheIdentifier, players);
|
||||
}
|
||||
} else {
|
||||
final Collection<? extends PlotPlayer<?>> onlinePlayers = PlotSquared.imp().getPlayerManager().getPlayers();
|
||||
final Collection<? extends PlotPlayer<?>> onlinePlayers = PlotSquared.platform().getPlayerManager().getPlayers();
|
||||
players = new ArrayList<>(onlinePlayers.size());
|
||||
for (final PlotPlayer<?> player : onlinePlayers) {
|
||||
if (uuidFilter.test(player.getUUID())) {
|
||||
|
@ -187,7 +187,7 @@ public abstract class WorldUtil {
|
||||
|
||||
public File getDat(String world) {
|
||||
File file = new File(
|
||||
PlotSquared.get().IMP.getWorldContainer() + File.separator + world + File.separator
|
||||
PlotSquared.platform().getWorldContainer() + File.separator + world + File.separator
|
||||
+ "level.dat");
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
@ -196,7 +196,7 @@ public abstract class WorldUtil {
|
||||
}
|
||||
|
||||
public File getMcr(String world, int x, int z) {
|
||||
File file = new File(PlotSquared.get().IMP.getWorldContainer(),
|
||||
File file = new File(PlotSquared.platform().getWorldContainer(),
|
||||
world + File.separator + "region" + File.separator + "r." + x + '.' + z + ".mca");
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
|
Loading…
Reference in New Issue
Block a user