Makes some smaller changes
Some checks failed
EpicKnarvik97/Stargate/pipeline/head There was a failure building this commit
Some checks failed
EpicKnarvik97/Stargate/pipeline/head There was a failure building this commit
Replaces the mystery code in sendMessage with translateAlternateColorCodes and removes the TODO Removes the TODO in deactivate() as it is actually necessary because fixed portals are always active Moves conflictsWithExistingGate to PortalCreator and removes the TODO for now Removes the extra spaces in >Random< Adjusts some comments Adds missing information about Economy and the requirement of UUIDs
This commit is contained in:
@ -50,9 +50,7 @@ public final class MessageSender {
|
||||
if (message.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
//Replace color codes with green? What's the deal with the dollar sign?
|
||||
//TODO: Figure out what this is actually supposed to do and do it in a better way
|
||||
message = message.replaceAll("(&([a-f0-9]))", "\u00A7$2");
|
||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||
if (error) {
|
||||
sender.sendMessage(ChatColor.RED + languageLoader.getString("prefix") + ChatColor.WHITE + message);
|
||||
} else {
|
||||
|
@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* This event should be called whenever a player attempts to access a stargate
|
||||
*
|
||||
* <p>This event is triggered whenever a player enters or activates a stargate. This event can be used to override
|
||||
* <p>This event is triggered whenever a player enters or activates a stargate. This event can be used to override
|
||||
* whether the player should be allowed to access the stargate.</p>
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -191,9 +191,7 @@ public class PortalActivator {
|
||||
//Un-mark the portal as activated
|
||||
Stargate.getStargateConfig().getActivePortalsQueue().remove(portal);
|
||||
|
||||
//For a fixed gate, the destinations and the sign never really change, but at the same time, fixed gates are
|
||||
// never really activated, so in theory, this check should be redundant.
|
||||
//TODO: Decide if this check is really useless
|
||||
//Fixed portals are active by definition, but should never be de-activated
|
||||
if (portal.getOptions().isFixed()) {
|
||||
return;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ public class PortalCreator {
|
||||
}
|
||||
|
||||
//Check if a conflict exists
|
||||
if (PortalHandler.conflictsWithExistingPortal(gate, portalLocation.getTopLeft(), yaw, player)) {
|
||||
if (conflictsWithExistingPortal(gate, portalLocation.getTopLeft(), yaw, player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -312,4 +312,25 @@ public class PortalCreator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the new portal conflicts with an existing portal
|
||||
*
|
||||
* @param gate <p>The gate type of the new portal</p>
|
||||
* @param topLeft <p>The top-left block of the new portal</p>
|
||||
* @param yaw <p>The yaw when looking directly outwards from the portal</p>
|
||||
* @param player <p>The player creating the new portal</p>
|
||||
* @return <p>True if a conflict was found. False otherwise</p>
|
||||
*/
|
||||
private static boolean conflictsWithExistingPortal(Gate gate, BlockLocation topLeft, double yaw, Player player) {
|
||||
for (RelativeBlockVector borderVector : gate.getLayout().getBorder()) {
|
||||
BlockLocation borderBlockLocation = topLeft.getRelativeLocation(borderVector, yaw);
|
||||
if (PortalHandler.getByBlock(borderBlockLocation.getBlock()) != null) {
|
||||
Stargate.debug("createPortal", "Gate conflicts with existing gate");
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("createConflict"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -86,11 +86,11 @@ public class PortalHandler {
|
||||
destinations.add(portal.getName());
|
||||
continue;
|
||||
}
|
||||
//Check if this player can access the dest world
|
||||
//Check if this player can access the destination world
|
||||
if (PermissionHelper.cannotAccessWorld(player, portal.getWorld().getName())) {
|
||||
continue;
|
||||
}
|
||||
//Visible to this player.
|
||||
//The portal is visible to the player
|
||||
if (PermissionHelper.canSeePortal(player, portal)) {
|
||||
destinations.add(portal.getName());
|
||||
}
|
||||
@ -170,30 +170,6 @@ public class PortalHandler {
|
||||
return gate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the new portal conflicts with an existing portal
|
||||
*
|
||||
* @param gate <p>The gate type of the new portal</p>
|
||||
* @param topLeft <p>The top-left block of the new portal</p>
|
||||
* @param yaw <p>The yaw when looking directly outwards from the portal</p>
|
||||
* @param player <p>The player creating the new portal</p>
|
||||
* @return <p>True if a conflict was found. False otherwise</p>
|
||||
*/
|
||||
static boolean conflictsWithExistingPortal(Gate gate, BlockLocation topLeft, double yaw, Player player) {
|
||||
//TODO: Make a quicker check. Could just check for control block conflicts if all code is changed to account for
|
||||
// getting several hits at a single location when checking for the existence of a portal. May make
|
||||
// everything slower overall? Would make for cooler gates though.
|
||||
for (RelativeBlockVector borderVector : gate.getLayout().getBorder()) {
|
||||
BlockLocation borderBlockLocation = topLeft.getRelativeLocation(borderVector, yaw);
|
||||
if (getByBlock(borderBlockLocation.getBlock()) != null) {
|
||||
Stargate.debug("createPortal", "Gate conflicts with existing gate");
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("createConflict"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the sign and open state of portals pointing at the newly created portal
|
||||
*
|
||||
|
@ -191,7 +191,7 @@ public class PortalSignDrawer {
|
||||
*/
|
||||
private void drawFixedSign(Sign sign) {
|
||||
if (portal.getOptions().isRandom()) {
|
||||
setLine(sign, 1, "> " + Stargate.getString("signRandom") + " <");
|
||||
setLine(sign, 1, ">" + Stargate.getString("signRandom") + "<");
|
||||
} else {
|
||||
setLine(sign, 1, ">" + portal.getDestinationName() + "<");
|
||||
}
|
||||
|
Reference in New Issue
Block a user