Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/main/java/org/mvplugins/multiverse/portals/MVPortal.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,16 @@ public static MVPortal loadMVPortalFromConfig(MultiversePortals instance, String
private Permission fillPermission;
private Permission exempt;

/**
* @deprecated Use {@link MVPortal(MultiverseWorld, MultiversePortals, String, String, String)} instead.
*/
@Deprecated(forRemoval = true, since = "5.3")
@ApiStatus.ScheduledForRemoval(inVersion = "6.0")
public MVPortal(LoadedMultiverseWorld world, MultiversePortals instance, String name, String owner, String location) {
this((MultiverseWorld) world, instance, name, owner, location);
}

@ApiStatus.AvailableSince("5.3")
public MVPortal(MultiverseWorld world, MultiversePortals instance, String name, String owner, String location) {
this(instance, name);
this.setOwner(owner);
Expand Down Expand Up @@ -328,6 +332,7 @@ public boolean setPortalLocation(String locationString, LoadedMultiverseWorld wo
return this.setPortalLocation(locationString, (MultiverseWorld) world);
}

@ApiStatus.AvailableSince("5.3")
public boolean setPortalLocation(String locationString, MultiverseWorld world) {
return this.setPortalLocation(PortalLocation.parseLocation(locationString, world, this.name));
}
Expand Down Expand Up @@ -468,21 +473,29 @@ private double getMinimumWith2Air(int finalX, int finalZ, int y, int yMax, World
* this gets the Material at the center of the portal.
*
* @return The Material that fills this portal.
* @throws IllegalStateException If this portal's location is no longer valid.
* @throws IllegalStateException If this portal's location is no longer valid or world is unloaded.
*/
public Material getFillMaterial() throws IllegalStateException {
if (!this.location.isValidLocation()) {
throw new IllegalStateException(String.format(
"Failed to get fill material from MV Portal (%s): Portal location is invalid.",
this.getName()));
}

World world = this.location.getMultiverseWorld()
.flatMap(MultiverseWorld::asLoadedWorld)
.flatMap(LoadedMultiverseWorld::getBukkitWorld)
.getOrNull();
if (world == null) {
String worldName = this.location.getMultiverseWorld()
.map(MultiverseWorld::getName)
.getOrElse("unknown");
throw new IllegalStateException(String.format(
"Failed to get fill material from MV Portal (%s): World '%s' is unloaded.",
this.getName(), worldName));
}
return this.location.getMinimum()
.getMidpoint(this.location.getMaximum())
.toLocation(this.location.getMultiverseWorld()
.flatMap(MultiverseWorld::asLoadedWorld)
.flatMap(LoadedMultiverseWorld::getBukkitWorld)
.getOrNull())
.toLocation(world)
.getBlock()
.getType();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
return parseLocation(locationString, (MultiverseWorld) world, portalName);
}

@ApiStatus.AvailableSince("5.3")
public static PortalLocation parseLocation(String locationString, MultiverseWorld world, String portalName) {
String[] split = locationString.split(":");
if (split.length != 2) {
Expand Down Expand Up @@ -88,6 +89,13 @@
public PortalLocation() {
}

@Deprecated(forRemoval = true, since = "5.3")
@ApiStatus.ScheduledForRemoval(inVersion = "6.0")
public PortalLocation(Vector pos1, Vector pos2, LoadedMultiverseWorld world) {

Check warning on line 94 in src/main/java/org/mvplugins/multiverse/portals/PortalLocation.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=Multiverse_Multiverse-Portals&issues=AaASthT4-OeNLKDHqaSJ&open=AaASthT4-OeNLKDHqaSJ&pullRequest=721

Check warning on line 94 in src/main/java/org/mvplugins/multiverse/portals/PortalLocation.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add the missing @deprecated Javadoc tag.

See more on https://sonarcloud.io/project/issues?id=Multiverse_Multiverse-Portals&issues=AaASthT4-OeNLKDHqaSK&open=AaASthT4-OeNLKDHqaSK&pullRequest=721
this(pos1, pos2, (MultiverseWorld) world);
}

@ApiStatus.AvailableSince("5.3")
public PortalLocation(Vector pos1, Vector pos2, MultiverseWorld world) {
this.validLocation = this.setLocation(pos1, pos2, world);
}
Expand All @@ -99,7 +107,7 @@
* @param maxPt
*/
public PortalLocation(BlockVector3 minPt, BlockVector3 maxPt, LoadedMultiverseWorld world) {
this(new Vector(minPt.getX(), minPt.getY(), minPt.getZ()), new Vector(maxPt.getX(), maxPt.getY(), maxPt.getZ()), world);
this(new Vector(minPt.getX(), minPt.getY(), minPt.getZ()), new Vector(maxPt.getX(), maxPt.getY(), maxPt.getZ()), (MultiverseWorld) world);
}

private static Vector parseVector(String vectorString) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.mvplugins.multiverse.core.locale.message.Message;
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
import org.mvplugins.multiverse.core.world.MultiverseWorld;
import org.mvplugins.multiverse.core.world.WorldManager;
import org.mvplugins.multiverse.portals.config.PortalsConfig;
import org.mvplugins.multiverse.portals.enums.MoveType;
Expand Down Expand Up @@ -153,7 +154,7 @@ public boolean setLeftClickSelection(Vector v, LoadedMultiverseWorld world) {
this.leftClickWorld = world;
String position = "(" + v.getBlockX() + ", " + v.getBlockY() + ", " + v.getBlockZ() + ")";
if (this.leftClickWorld == this.rightClickWorld && this.rightClick != null) {
MultiverseRegion tempReg = new MultiverseRegion(this.leftClick, this.rightClick, this.leftClickWorld);
MultiverseRegion tempReg = new MultiverseRegion(this.leftClick, this.rightClick, (MultiverseWorld) this.leftClickWorld);
this.issuer.sendInfo(MVPi18n.SELECTION_FIRST_AREA,
replace("{position}").with(position),
Replace.COUNT.with(tempReg.getArea()));
Expand All @@ -172,7 +173,7 @@ public boolean setRightClickSelection(Vector v, LoadedMultiverseWorld world) {
this.rightClickWorld = world;
String position = "(" + v.getBlockX() + ", " + v.getBlockY() + ", " + v.getBlockZ() + ")";
if (this.leftClickWorld == this.rightClickWorld && this.leftClick != null) {
MultiverseRegion tempReg = new MultiverseRegion(this.leftClick, this.rightClick, this.leftClickWorld);
MultiverseRegion tempReg = new MultiverseRegion(this.leftClick, this.rightClick, (MultiverseWorld) this.leftClickWorld);
this.issuer.sendInfo(MVPi18n.SELECTION_SECOND_AREA,
replace("{position}").with(position),
Replace.COUNT.with(tempReg.getArea()));
Expand All @@ -192,7 +193,7 @@ public MultiverseRegion getSelectedRegion() {
Location maxPoint = worldEdit.getSelectionMaxPoint(this.player);
if (minPoint != null && maxPoint != null && minPoint.getWorld().equals(maxPoint.getWorld())) {
return new MultiverseRegion(minPoint, maxPoint,
this.worldManager.getLoadedWorld(minPoint.getWorld().getName()).getOrNull());
this.worldManager.getWorld(minPoint.getWorld().getName()).getOrNull());
} else {
this.issuer.sendError(MVPi18n.SELECTION_WORLDEDIT_INCOMPLETE);
return null;
Expand All @@ -217,7 +218,7 @@ public MultiverseRegion getSelectedRegion() {
replace("{rightWorld}").with(this.rightClickWorld.getAlias()));
return null;
}
return new MultiverseRegion(this.leftClick, this.rightClick, this.leftClickWorld);
return new MultiverseRegion(this.leftClick, this.rightClick, (MultiverseWorld) this.leftClickWorld);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.mvplugins.multiverse.core.destination.DestinationInstance;
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
import org.mvplugins.multiverse.core.world.MultiverseWorld;
import org.mvplugins.multiverse.external.acf.commands.annotation.CommandAlias;
import org.mvplugins.multiverse.external.acf.commands.annotation.CommandCompletion;
import org.mvplugins.multiverse.external.acf.commands.annotation.CommandPermission;
Expand Down Expand Up @@ -76,7 +77,7 @@ void onCreateCommand(
}

MVPortal portal = this.portalManager.getPortal(portalName);
PortalLocation location = new PortalLocation(region.getMinimumPoint(), region.getMaximumPoint(), world);
PortalLocation location = new PortalLocation(region.getMinimumPoint(), region.getMaximumPoint(), (MultiverseWorld) world);
if (this.portalManager.addPortal(world, portalName, player.getName(), location)) {
issuer.sendInfo(MVPi18n.CREATE_SUCCESS, Replace.NAME.with(portalName));
// If the portal did not exist, ie: we're creating it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ public class MultiverseRegion {
private final Vector max;
private final MultiverseWorld world;

public MultiverseRegion(Object pos1, Object pos2, MultiverseWorld w) {
/**
* @deprecated Use {@link MultiverseRegion(Object, Object, MultiverseWorld)} instead.
*/
@Deprecated(forRemoval = true, since = "5.3")
@ApiStatus.ScheduledForRemoval(inVersion = "6.0")
public MultiverseRegion(Object pos1, Object pos2, LoadedMultiverseWorld w) {
this(pos1, pos2, (MultiverseWorld) w);
}

@ApiStatus.AvailableSince("5.3")
public MultiverseRegion(Object pos1, Object pos2, MultiverseWorld w) {
// Creating soft dependencies on WE
if (pos1 instanceof com.sk89q.worldedit.math.BlockVector3 && pos2 instanceof com.sk89q.worldedit.math.BlockVector3) {
com.sk89q.worldedit.math.BlockVector3 weV1 = (com.sk89q.worldedit.math.BlockVector3) pos1;
Expand All @@ -36,15 +46,36 @@ public MultiverseRegion(Object pos1, Object pos2, MultiverseWorld w) {
this.min = Vector.getMinimum(tmp1, tmp2);
this.max = Vector.getMaximum(tmp1, tmp2);
this.world = w;
return;
}
throw new UnsupportedOperationException("WorldEdit plugin not installed!");
}

public MultiverseRegion(Location loc1, Location loc2, MultiverseWorld w) {
/**
* @deprecated Use {@link MultiverseRegion(Location, Location, MultiverseWorld)} instead.
*/
@Deprecated(forRemoval = true, since = "5.3")
@ApiStatus.ScheduledForRemoval(inVersion = "6.0")
public MultiverseRegion(Location loc1, Location loc2, LoadedMultiverseWorld w) {
this(loc1.toVector(), loc2.toVector(), (MultiverseWorld) w);
}

@ApiStatus.AvailableSince("5.3")
public MultiverseRegion(Location loc1, Location loc2, MultiverseWorld w) {
this(loc1.toVector(), loc2.toVector(), w);
}

public MultiverseRegion(Vector pos1, Vector pos2, MultiverseWorld w) {
/**
* @deprecated Use {@link MultiverseRegion(Vector, Vector, MultiverseWorld)} instead.
*/
@Deprecated(forRemoval = true, since = "5.3")
@ApiStatus.ScheduledForRemoval(inVersion = "6.0")
public MultiverseRegion(Vector pos1, Vector pos2, LoadedMultiverseWorld w) {
this(pos1, pos2, (MultiverseWorld) w);
}

@ApiStatus.AvailableSince("5.3")
public MultiverseRegion(Vector pos1, Vector pos2, MultiverseWorld w) {
this.min = Vector.getMinimum(pos1, pos2);
this.max = Vector.getMaximum(pos1, pos2);
this.world = w;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.Location;
Expand All @@ -38,7 +37,6 @@
import org.mvplugins.multiverse.portals.PortalLocation;
import org.mvplugins.multiverse.portals.config.PortalsConfig;


/**
* Manages all portals for all worlds.
*
Expand Down Expand Up @@ -278,7 +276,7 @@ public List<MVPortal> getPortals(CommandSender sender, MultiverseWorld world) {
if (portalsConfig.getEnforcePortalAccess()) {
for (MVPortal p : all) {
if (p.getPortalLocation().isValidLocation()
&& Objects.equals(p.getPortalLocation().getMultiverseWorld(), world)
&& p.getPortalLocation().getMultiverseWorld().exists(world::equals)
&& p.playerCanEnterPortal((Player) sender)) {
validItems.add(p);
}
Expand Down
Loading