Remove access to PlotSquared#IMP and rename IPlotMain to PlotPlatform, then rename PlotSquared#imp() to PlotSquared#platform()

This commit is contained in:
Alexander Söderberg
2020-07-07 12:56:43 +02:00
parent b5818bfefc
commit d76c9dad52
63 changed files with 211 additions and 210 deletions

View File

@ -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;

View File

@ -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));

View File

@ -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) {

View File

@ -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;

View File

@ -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()));
}
}
}

View File

@ -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));
}
}

View File

@ -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 "";

View File

@ -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 {

View File

@ -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;
}

View File

@ -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);

View File

@ -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) {

View File

@ -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;
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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) {

View File

@ -1,5 +1,5 @@
name: ${name}
main: com.plotsquared.bukkit.BukkitMain
main: com.plotsquared.bukkit.BukkitPlatform
api-version: "1.13"
version: "${version}"
load: STARTUP