Compare commits
9 Commits
yml-storag
...
0.11.5.12
| Author | SHA1 | Date | |
|---|---|---|---|
| 24ef1cde02 | |||
| 9b28107db8 | |||
| 99c3b611dc | |||
| 07463f77d9 | |||
| bbb5c5184e | |||
| 69e334c195 | |||
| 3e0b38c3d0 | |||
| 2bf9f13379 | |||
| 89a68b40b1 |
26
README.md
26
README.md
@@ -31,7 +31,7 @@ Highly capable, simple to use, with robust network capabilities and extensive cu
|
||||
- LockedCraft and LittleBigBug also forked that version to add underwater and tag support, as well as a few bug fixes.
|
||||
- This version is a combination of all the forks above, maintained by EpicKnarvik97.
|
||||
- A rewrite was underway, but because of a mix of real life obligations, and a general lack of motivation, progress
|
||||
stopped.
|
||||
stopped. Some features/improvements have found its way from the rewrite to this version over time.
|
||||
|
||||
## License
|
||||
|
||||
@@ -489,6 +489,7 @@ Please note that %variableName% should be kept, as it will be replaced with a re
|
||||
|-----------------------|--------------------------------------------------------------------|
|
||||
| prefix | \[Stargate] |
|
||||
| teleportMsg | Teleported |
|
||||
| teleportationFailed | Teleportation was cancelled or denied |
|
||||
| destroyMsg | Gate Destroyed |
|
||||
| invalidMsg | Invalid Destination |
|
||||
| blockMsg | Destination Blocked |
|
||||
@@ -535,6 +536,25 @@ Please note that %variableName% should be kept, as it will be replaced with a re
|
||||
|
||||
# Changes
|
||||
|
||||
#### \[Version 0.11.5.12] Unified Legacy Fork
|
||||
|
||||
- Fixes gate verification incorrectly treating valid Stargates as invalid
|
||||
- Improves the default permissions of players to allow personal creation of standard nether stargates, and general
|
||||
Stargate use.
|
||||
- Adds three new permission groups for easier permission setup: stargate.group.admin, stargate.group.builder,
|
||||
stargate.group.player. The builder group allows creation and destruction of all Stargates, and usage of all
|
||||
options/flags except bungee portals.
|
||||
- Fixes end gateways not teleporting players unless sneaking into the portal on newer Minecraft versions.
|
||||
- Adds an error message in case Stargate detects some other plugin cancelled or interfered with its teleportation.
|
||||
- Stops some debug output during startup when debug is disabled
|
||||
- Renames the silent option to quiet internally to better match the Q character used to enable the option.
|
||||
- Replaces code for message formatting
|
||||
- Improves some error messages
|
||||
- Replaces some code with KnarLib implementations
|
||||
- Updates some dependencies
|
||||
- Restructures all event code, and improves Stargate protection
|
||||
- Removes static permission strings, and removes redundancy in permission checking code
|
||||
|
||||
#### \[Version 0.11.5.11] Unified Legacy Fork
|
||||
|
||||
- Removes legacy sign drawing code, as the check for whether a server supported the sign sides kept failing for some
|
||||
@@ -545,7 +565,7 @@ Please note that %variableName% should be kept, as it will be replaced with a re
|
||||
#### \[Version 0.11.5.10] Unified Legacy Fork
|
||||
|
||||
- Fixed a problem with material tag support
|
||||
- Made serveral optimisations to significantly improve performance on servers with high playercounts.
|
||||
- Made serveral optimisations to significantly improve performance on servers with high player counts.
|
||||
|
||||
#### \[Version 0.11.5.9] Unified Legacy Fork
|
||||
|
||||
@@ -571,7 +591,7 @@ Please note that %variableName% should be kept, as it will be replaced with a re
|
||||
|
||||
- Fixed a potential stack trace experienced when disabling Dynmap
|
||||
- Fixed some problems related to negative economy transactions.
|
||||
- Fixed an exception occuring when negative yaw values are encountered.
|
||||
- Fixed an exception occurring when negative yaw values are encountered.
|
||||
- Updated the about command and added a debug command.
|
||||
|
||||
#### \[Version 0.11.5.5] Unified Legacy Fork
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>net.knarcraft</groupId>
|
||||
<artifactId>Stargate</artifactId>
|
||||
<version>0.11.5.12-SNAPSHOT</version>
|
||||
<version>0.11.5.12</version>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
||||
@@ -15,7 +15,7 @@ public enum Permission {
|
||||
|
||||
SEE_HIDDEN("admin.hidden"),
|
||||
USE_PRIVATE("admin.private"),
|
||||
|
||||
|
||||
FREE_USAGE("free.use"),
|
||||
FREE_DESTRUCTION("free.destroy"),
|
||||
FREE_CREATION("free.create"),
|
||||
|
||||
@@ -92,6 +92,7 @@ public final class StargateConfig {
|
||||
*/
|
||||
public void finishSetup() {
|
||||
this.loadConfig();
|
||||
this.isLoaded = true;
|
||||
|
||||
//Enable the required channels for Bungee support
|
||||
if (stargateGateConfig.enableBungee()) {
|
||||
@@ -133,8 +134,6 @@ public final class StargateConfig {
|
||||
"integration is disabled.");
|
||||
DynmapManager.disable();
|
||||
}
|
||||
|
||||
this.isLoaded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -202,6 +202,11 @@ public enum Message {
|
||||
* The author that created the loaded translation
|
||||
*/
|
||||
AUTHOR("author"),
|
||||
|
||||
/**
|
||||
* The error message to display when a teleportation fails for whatever reason
|
||||
*/
|
||||
TELEPORTATION_FAILED("teleportationFailed"),
|
||||
;
|
||||
|
||||
private final String key;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.knarcraft.stargate.container;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -22,28 +21,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public record RelativeBlockVector(int right, int down, int out) {
|
||||
|
||||
/**
|
||||
* Adds the given value to this relative block vector's "right" property
|
||||
*
|
||||
* @param valueToAdd <p>The value to add</p>
|
||||
* @return <p>The new resulting vector</p>
|
||||
*/
|
||||
@NotNull
|
||||
public RelativeBlockVector addRight(int valueToAdd) {
|
||||
return new RelativeBlockVector(this.right + valueToAdd, this.down, this.out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given value to this relative block vector's "down" property
|
||||
*
|
||||
* @param valueToAdd <p>The value to add</p>
|
||||
* @return <p>The new resulting vector</p>
|
||||
*/
|
||||
@NotNull
|
||||
public RelativeBlockVector addDown(int valueToAdd) {
|
||||
return new RelativeBlockVector(this.right, this.down + valueToAdd, this.out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given value to this relative block vector's "out" property
|
||||
*
|
||||
@@ -55,15 +32,6 @@ public record RelativeBlockVector(int right, int down, int out) {
|
||||
return new RelativeBlockVector(this.right, this.down, this.out + valueToAdd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a relative vector in the real space representing this relative block vector
|
||||
*
|
||||
* @return <p>A vector representing this relative block vector</p>
|
||||
*/
|
||||
public Vector toVector() {
|
||||
return new Vector(this.right, -this.down, this.out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a relative block vector which is this inverted (pointing in the opposite direction)
|
||||
*
|
||||
|
||||
@@ -63,15 +63,24 @@ public class StargateTeleportListener implements Listener {
|
||||
*
|
||||
* @param event <p>The event to check and possibly cancel</p>
|
||||
*/
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerTeleport(@NotNull PlayerTeleportEvent event) {
|
||||
PlayerTeleportEvent.TeleportCause cause = event.getCause();
|
||||
|
||||
//Block normal portal teleportation if teleporting from a stargate
|
||||
if (!event.isCancelled() && (cause == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL ||
|
||||
cause == PlayerTeleportEvent.TeleportCause.END_GATEWAY ||
|
||||
if ((cause == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL ||
|
||||
cause == PlayerTeleportEvent.TeleportCause.END_PORTAL)
|
||||
&& PortalHandler.getByAdjacentEntrance(event.getFrom()) != null) {
|
||||
Stargate.debug("StargateTeleportListener::onPlayerTeleport",
|
||||
"Cancelled vanilla portal event to " + event.getTo());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// Cancel end gateway teleportation to the same destination
|
||||
if (event.getTo() != null && cause == PlayerTeleportEvent.TeleportCause.END_GATEWAY &&
|
||||
PortalHandler.getByAdjacentEntrance(event.getFrom()) != null &&
|
||||
event.getFrom().getWorld() != null && event.getFrom().getWorld().equals(event.getTo().getWorld()) &&
|
||||
event.getFrom().distance(event.getTo()) <= 1) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -388,6 +397,7 @@ public class StargateTeleportListener implements Listener {
|
||||
*/
|
||||
private void teleportPlayer(@Nullable Entity playerVehicle, @NotNull Player player, @NotNull Portal entrancePortal,
|
||||
@NotNull Portal destination, @NotNull PlayerMoveEvent event) {
|
||||
boolean success = true;
|
||||
if (playerVehicle instanceof LivingEntity) {
|
||||
//Make sure any horses are properly tamed
|
||||
if (playerVehicle instanceof AbstractHorse horse && !horse.isTamed()) {
|
||||
@@ -399,10 +409,12 @@ public class StargateTeleportListener implements Listener {
|
||||
new VehicleTeleporter(destination, (Vehicle) playerVehicle).teleportEntity(entrancePortal);
|
||||
} else {
|
||||
//Just teleport the player like normal
|
||||
new PlayerTeleporter(destination, player).teleportPlayer(entrancePortal, event);
|
||||
success = new PlayerTeleporter(destination, player).teleportPlayer(entrancePortal, event);
|
||||
}
|
||||
if (!entrancePortal.getOptions().isQuiet()) {
|
||||
if (success && !entrancePortal.getOptions().isQuiet()) {
|
||||
new SGFormatBuilder(Message.TELEPORTED).success(player);
|
||||
} else if (!success) {
|
||||
new SGFormatBuilder(Message.TELEPORTATION_FAILED).error(player);
|
||||
}
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
}
|
||||
@@ -462,8 +474,10 @@ public class StargateTeleportListener implements Listener {
|
||||
*/
|
||||
private Portal getEnteredPortal(@NotNull BlockLocation toLocation, @NotNull Player player) {
|
||||
Portal entrancePortal = PortalHandler.getByEntrance(toLocation);
|
||||
|
||||
// Return if in an entrance
|
||||
if (entrancePortal != null) {
|
||||
Stargate.debug("StargateTeleportListener::getEnteredPortal", "Player entered portal " + entrancePortal);
|
||||
return entrancePortal;
|
||||
}
|
||||
|
||||
@@ -473,6 +487,8 @@ public class StargateTeleportListener implements Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
Stargate.debug("StargateTeleportListener::getEnteredPortal", "Player entered adjacent portal " + entrancePortal);
|
||||
|
||||
// If END_GATEWAY and END_PORTAL cannot appear, skip further checks
|
||||
Set<Material> entranceMaterials = MaterialHelper.specifiersToMaterials(entrancePortal.getGate().getPortalOpenMaterials());
|
||||
if (!entranceMaterials.contains(Material.END_GATEWAY) && !entranceMaterials.contains(Material.END_PORTAL)) {
|
||||
|
||||
@@ -9,8 +9,6 @@ import net.knarcraft.stargate.portal.property.PortalOwner;
|
||||
import net.knarcraft.stargate.portal.property.PortalStrings;
|
||||
import net.knarcraft.stargate.portal.property.PortalStructure;
|
||||
import net.knarcraft.stargate.portal.property.gate.Gate;
|
||||
import net.knarcraft.stargate.transformation.SimpleVectorOperation;
|
||||
import net.knarcraft.stargate.utility.DirectionHelper;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -28,7 +26,6 @@ public class Portal {
|
||||
private final String cleanName;
|
||||
private final String network;
|
||||
private final String cleanNetwork;
|
||||
private final SimpleVectorOperation vectorOperation;
|
||||
|
||||
private final PortalOwner portalOwner;
|
||||
private boolean isRegistered;
|
||||
@@ -64,7 +61,6 @@ public class Portal {
|
||||
this.portalActivator = portalOpener.getPortalActivator();
|
||||
this.cleanName = cleanString(name);
|
||||
this.cleanNetwork = cleanString(network);
|
||||
this.vectorOperation = new SimpleVectorOperation(DirectionHelper.getBlockFaceFromYaw(portalLocation.getYaw()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,7 +313,7 @@ public class Portal {
|
||||
*/
|
||||
@NotNull
|
||||
public BlockLocation getBlockAt(@NotNull RelativeBlockVector vector) {
|
||||
return (BlockLocation) getTopLeft().clone().add(vectorOperation.performToRealSpaceOperation(vector.toVector()));
|
||||
return getTopLeft().getRelativeLocation(vector, this.getYaw());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,15 +71,18 @@ public class PortalHandler {
|
||||
List<String> destinations = new ArrayList<>();
|
||||
List<String> portalsInNetwork = PortalRegistry.getNetwork(network);
|
||||
if (portalsInNetwork == null) {
|
||||
Stargate.debug("PortalHandler::getDestinations", "Portal network " + network + " is null");
|
||||
return List.of();
|
||||
}
|
||||
for (String destination : portalsInNetwork) {
|
||||
Portal portal = getByName(destination, network);
|
||||
if (portal == null) {
|
||||
Stargate.debug("PortalHandler::getDestinations", "Invalid portal with name " + destination);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isDestinationAvailable(entrancePortal, portal, player)) {
|
||||
Stargate.debug("PortalHandler::getDestinations", "Found available destination " + portal.getName());
|
||||
destinations.add(portal.getName());
|
||||
}
|
||||
}
|
||||
@@ -120,6 +123,7 @@ public class PortalHandler {
|
||||
//Check if this player can access the destination world
|
||||
if (destinationPortal.getWorld() != null && PermissionHelper.cannotAccessWorld(player,
|
||||
destinationPortal.getWorld().getName())) {
|
||||
Stargate.debug("PortalHandler::isDestinationAvailable", "Missing permission for destination world");
|
||||
return false;
|
||||
}
|
||||
//The portal is visible to the player
|
||||
@@ -473,7 +477,8 @@ public class PortalHandler {
|
||||
if (!MaterialHelper.specifiersToMaterials(portal.getGate().getControlBlockMaterials()).contains(
|
||||
block.getType())) {
|
||||
Stargate.debug("PortalHandler::unregisterInvalidPortal", "Control Block Type == " +
|
||||
block.getType().name());
|
||||
block.getType().name() + " at " + control + " real: " + block + " facing " +
|
||||
portal.getLocation().getYaw());
|
||||
}
|
||||
}
|
||||
PortalRegistry.unregisterPortal(portal, false);
|
||||
|
||||
@@ -39,7 +39,8 @@ public class PlayerTeleporter extends Teleporter {
|
||||
* @param origin <p>The portal the player teleports from</p>
|
||||
* @param event <p>The player move event triggering the event</p>
|
||||
*/
|
||||
public void teleportPlayer(@NotNull Portal origin, @Nullable PlayerMoveEvent event) {
|
||||
public boolean teleportPlayer(@NotNull Portal origin, @Nullable PlayerMoveEvent event) {
|
||||
boolean success = true;
|
||||
double velocity = player.getVelocity().length();
|
||||
List<Entity> passengers = player.getPassengers();
|
||||
|
||||
@@ -47,7 +48,7 @@ public class PlayerTeleporter extends Teleporter {
|
||||
if (!origin.equals(portal)) {
|
||||
exit = triggerPortalEvent(origin, new StargatePlayerPortalEvent(player, origin, portal, exit));
|
||||
if (exit == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,14 +68,18 @@ public class PlayerTeleporter extends Teleporter {
|
||||
|
||||
//If no event is passed in, assume it's a teleport, and act as such
|
||||
if (event == null) {
|
||||
player.teleport(exit);
|
||||
success &= player.teleport(exit);
|
||||
Stargate.debug("PlayerTeleporter::teleportPlayer", "Teleported player to " + exit);
|
||||
} else {
|
||||
//Set the exit location of the event
|
||||
success &= !event.isCancelled();
|
||||
event.setTo(exit);
|
||||
Stargate.debug("PlayerTeleporter::teleportPlayer", "Overwrote movement event to " + exit);
|
||||
}
|
||||
|
||||
//Set the velocity of the teleported player after the teleportation is finished
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Stargate.getInstance(), () -> player.setVelocity(newVelocity), 1);
|
||||
return success;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
package net.knarcraft.stargate.transformation;
|
||||
|
||||
import org.bukkit.Axis;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A class for performing rotational operations on vectors
|
||||
*
|
||||
* @author Kristian Knarvik
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class SimpleVectorOperation {
|
||||
|
||||
private static final Map<BlockFace, Double> rotationAngles = new HashMap<>();
|
||||
private static final Map<BlockFace, Vector> rotationAxes = new HashMap<>();
|
||||
private static final Map<BlockFace, Axis> normalAxes = new HashMap<>();
|
||||
private static final BlockFace defaultDirection = BlockFace.SOUTH;
|
||||
private static final Axis defaultVerticalAxis = Axis.Y;
|
||||
|
||||
private final Axis normalAxis;
|
||||
private boolean flipZAxis = false;
|
||||
private final BlockFace facing;
|
||||
|
||||
/**
|
||||
* Instantiates a vector operation to rotate vectors in the direction of a sign face
|
||||
*
|
||||
* @param signFace <p>The sign face of a gate's sign</p>
|
||||
*/
|
||||
public SimpleVectorOperation(@NotNull BlockFace signFace) {
|
||||
if (normalAxes.isEmpty()) {
|
||||
initializeIrisNormalAxes();
|
||||
initializeOperations();
|
||||
}
|
||||
|
||||
this.facing = signFace;
|
||||
this.normalAxis = normalAxes.get(signFace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the block face of a sign given upon instantiation
|
||||
*
|
||||
* @return <p>The block face of a sign given upon instantiation</p>
|
||||
*/
|
||||
@NotNull
|
||||
public BlockFace getFacing() {
|
||||
return facing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the normal axis orthogonal to the opening plane
|
||||
*
|
||||
* <p>Said another way, get the axis going directly towards or away from a stargate's entrance.</p>
|
||||
*
|
||||
* @return <p>The normal axis orthogonal to the opening plane</p>
|
||||
*/
|
||||
@NotNull
|
||||
public Axis getNormalAxis() {
|
||||
return normalAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to flip the Z- axis
|
||||
*
|
||||
* @param flipZAxis <p>Whether to flip the z-axis</p>
|
||||
*/
|
||||
public void setFlipZAxis(boolean flipZAxis) {
|
||||
this.flipZAxis = flipZAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an operation from the real space to the vector space
|
||||
*
|
||||
* @param vector <p>The vector to perform the operation on</p>
|
||||
* @return vector <p>A new vector with the operation applied</p>
|
||||
*/
|
||||
@NotNull
|
||||
public Vector performToAbstractSpaceOperation(@NotNull Vector vector) {
|
||||
Vector clone = vector.clone();
|
||||
clone.rotateAroundAxis(rotationAxes.get(facing), rotationAngles.get(facing));
|
||||
if (flipZAxis) {
|
||||
clone.setZ(-clone.getZ());
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an operation from the vector space to the real space
|
||||
*
|
||||
* @param vector <p>The vector to perform the inverse operation on</p>
|
||||
* @return vector <p>A new vector with the operation applied</p>
|
||||
*/
|
||||
@NotNull
|
||||
public Vector performToRealSpaceOperation(@NotNull Vector vector) {
|
||||
Vector clone = vector.clone();
|
||||
if (flipZAxis) {
|
||||
clone.setZ(-clone.getZ());
|
||||
}
|
||||
return clone.rotateAroundAxis(rotationAxes.get(facing), -rotationAngles.get(facing));
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an operation from the vector space to the real space
|
||||
*
|
||||
* @param vector <p>The vector to perform the inverse operation on</p>
|
||||
* @return vector <p>A new vector with the operation applied</p>
|
||||
*/
|
||||
@NotNull
|
||||
public BlockVector performToRealSpaceOperation(@NotNull BlockVector vector) {
|
||||
return performToRealSpaceOperation((Vector) vector).toBlockVector();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the operations used for rotating to each block-face
|
||||
*/
|
||||
private static void initializeOperations() {
|
||||
Map<Axis, Vector> axisVectors = new HashMap<>();
|
||||
axisVectors.put(Axis.Y, new Vector(0, 1, 0));
|
||||
axisVectors.put(Axis.X, new Vector(1, 0, 0));
|
||||
axisVectors.put(Axis.Z, new Vector(0, 0, 1));
|
||||
|
||||
//Use the cross product to find the correct axis
|
||||
for (BlockFace face : normalAxes.keySet()) {
|
||||
Vector crossProduct = face.getDirection().crossProduct(defaultDirection.getDirection());
|
||||
if (face == defaultDirection || face == defaultDirection.getOppositeFace()) {
|
||||
rotationAxes.put(face, axisVectors.get(defaultVerticalAxis));
|
||||
} else if (Math.abs(crossProduct.getZ()) > 0) {
|
||||
rotationAxes.put(face, axisVectors.get(Axis.Z));
|
||||
} else if (Math.abs(crossProduct.getY()) > 0) {
|
||||
rotationAxes.put(face, axisVectors.get(Axis.Y));
|
||||
} else {
|
||||
rotationAxes.put(face, axisVectors.get(Axis.X));
|
||||
}
|
||||
}
|
||||
|
||||
calculateRotations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the required rotations based on the default rotation
|
||||
*/
|
||||
private static void calculateRotations() {
|
||||
double halfRotation = Math.PI;
|
||||
double quarterRotation = halfRotation / 2;
|
||||
|
||||
Vector defaultDirectionVector = defaultDirection.getDirection();
|
||||
boolean defaultDirectionPositive = defaultDirectionVector.getX() + defaultDirectionVector.getY() +
|
||||
defaultDirectionVector.getZ() > 0;
|
||||
|
||||
for (BlockFace blockFace : normalAxes.keySet()) {
|
||||
if (defaultDirection == blockFace) {
|
||||
//The default direction requires no rotation
|
||||
rotationAngles.put(blockFace, 0d);
|
||||
} else if (defaultDirection.getOppositeFace() == blockFace) {
|
||||
//The opposite direction requires a half rotation
|
||||
rotationAngles.put(blockFace, halfRotation);
|
||||
} else {
|
||||
//All the other used directions require a quarter rotation
|
||||
Vector faceDirectionVector = blockFace.getDirection();
|
||||
boolean faceDirectionPositive = faceDirectionVector.getX() + faceDirectionVector.getY() +
|
||||
faceDirectionVector.getZ() > 0;
|
||||
double rotation = defaultDirectionPositive && faceDirectionPositive ? quarterRotation : -quarterRotation;
|
||||
rotationAngles.put(blockFace, rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the iris normal axes corresponding to each block face
|
||||
*/
|
||||
private static void initializeIrisNormalAxes() {
|
||||
normalAxes.put(BlockFace.EAST, Axis.Z);
|
||||
normalAxes.put(BlockFace.WEST, Axis.Z);
|
||||
normalAxes.put(BlockFace.NORTH, Axis.X);
|
||||
normalAxes.put(BlockFace.SOUTH, Axis.X);
|
||||
normalAxes.put(BlockFace.UP, Axis.Y);
|
||||
normalAxes.put(BlockFace.DOWN, Axis.Y);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -219,7 +219,7 @@ public final class PermissionHelper {
|
||||
* @return <p>False if the player should be allowed to access the world</p>
|
||||
*/
|
||||
public static boolean cannotAccessWorld(@NotNull Player player, @NotNull String world) {
|
||||
return hasPermission(player, Permission.ACCESS_WORLD, world);
|
||||
return !hasPermission(player, Permission.ACCESS_WORLD, world);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,4 +38,5 @@ signRightClick=Right click
|
||||
signToUse=to use gate
|
||||
teleportMsg=Teleported
|
||||
vaultLoadError=Economy is enabled but Vault could not be loaded. Economy disabled
|
||||
vaultLoaded=Vault v%version% found
|
||||
vaultLoaded=Vault v%version% found
|
||||
teleportationFailed=Teleportation was cancelled or denied
|
||||
@@ -1,54 +0,0 @@
|
||||
package net.knarcraft.stargate.container;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class RelativeBlockVectorTest {
|
||||
|
||||
@Test
|
||||
public void addToVectorTest() {
|
||||
int right = 5;
|
||||
int down = 5;
|
||||
int out = 3;
|
||||
|
||||
RelativeBlockVector relativeBlockVector = new RelativeBlockVector(right, down, out);
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
int randomValue = getRandomNumber();
|
||||
RelativeBlockVector newVector = relativeBlockVector.addRight(randomValue);
|
||||
assertEquals(new RelativeBlockVector(right + randomValue, down, out), newVector);
|
||||
|
||||
newVector = relativeBlockVector.addOut(randomValue);
|
||||
assertEquals(new RelativeBlockVector(right, down, out + randomValue), newVector);
|
||||
|
||||
newVector = relativeBlockVector.addDown(randomValue);
|
||||
assertEquals(new RelativeBlockVector(right, down + randomValue, out), newVector);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invertTest() {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
int randomNumber1 = getRandomNumber();
|
||||
int randomNumber2 = getRandomNumber();
|
||||
int randomNumber3 = getRandomNumber();
|
||||
|
||||
RelativeBlockVector relativeBlockVector = new RelativeBlockVector(randomNumber1, randomNumber2,
|
||||
randomNumber3);
|
||||
RelativeBlockVector invertedBlockVector = new RelativeBlockVector(-randomNumber1, -randomNumber2,
|
||||
-randomNumber3);
|
||||
assertEquals(invertedBlockVector, relativeBlockVector.invert());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a random number between -500 and 500
|
||||
*
|
||||
* @return <p>A random number between -500 and 500</p>
|
||||
*/
|
||||
private int getRandomNumber() {
|
||||
return (int) ((Math.random() - 0.5) * 1000);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user