Makes some smaller changes
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:
Kristian Knarvik 2021-10-31 14:05:06 +01:00
parent 1f1fef3054
commit d754247455
7 changed files with 40 additions and 42 deletions

View File

@ -22,18 +22,23 @@ version of Stargate compliant with Spigot 1.17, even if it means changing the en
## Migration ## Migration
This plugin should be compatible with configurations from the Stargate plugin all the way back. The nethergate.gate This plugin should be compatible with configurations from the Stargate plugin all the way back. The nethergate.gate
file, the endgate.gate file and the watergate.gate file will be overwritten if they exist. Take a backup of the files file, the endgate.gate file and the watergate.gate file will be overwritten if they exist. Take a backup of the files
and overwrite the files after the first startup if you want to keep your custom gates. and overwrite the files after the first startup if you want to keep your custom gates.
If you have legacy gate files using the old numeric material ids, you need to change them to the new format manually. If you have legacy gate files using the old numeric material ids, you need to change them to the new format manually.
Use F3 + H to see material ids. Use them exactly as written after "minecraft:". Use F3 + H to see material ids. Use them exactly as written after "minecraft:". The configuration will be updated to a
The configuration will be updated to a more easily readable format, but the old configuration will be saved in case you more easily readable format, but the old configuration will be saved in case you want to change back right away.
want to change back right away.
Permissions have had a few changes, so you should check the permissions section for any differences since you set up Permissions have had a few changes, so you should check the permissions section for any differences since you set up
permissions. permissions.
Payment to owner using Economy, through Vault, is only possible if the portal owner in the portal database is defined by
a UUID, and not a username. Right now, there is no automatic upgrade from usernames to UUID. You must either make the
stargate owner re-create the stargate or edit the file in the portals folder in a text editor. There are various ways to
find the UUID of players. You may look in the usercache.json file in the server directory or search for the username on
various websites.
# Permissions # Permissions
``` ```

View File

@ -50,9 +50,7 @@ public final class MessageSender {
if (message.isEmpty()) { if (message.isEmpty()) {
return; return;
} }
//Replace color codes with green? What's the deal with the dollar sign? message = ChatColor.translateAlternateColorCodes('&', message);
//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");
if (error) { if (error) {
sender.sendMessage(ChatColor.RED + languageLoader.getString("prefix") + ChatColor.WHITE + message); sender.sendMessage(ChatColor.RED + languageLoader.getString("prefix") + ChatColor.WHITE + message);
} else { } else {

View File

@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
/** /**
* This event should be called whenever a player attempts to access a stargate * 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> * whether the player should be allowed to access the stargate.</p>
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")

View File

@ -191,9 +191,7 @@ public class PortalActivator {
//Un-mark the portal as activated //Un-mark the portal as activated
Stargate.getStargateConfig().getActivePortalsQueue().remove(portal); 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 //Fixed portals are active by definition, but should never be de-activated
// never really activated, so in theory, this check should be redundant.
//TODO: Decide if this check is really useless
if (portal.getOptions().isFixed()) { if (portal.getOptions().isFixed()) {
return; return;
} }

View File

@ -147,7 +147,7 @@ public class PortalCreator {
} }
//Check if a conflict exists //Check if a conflict exists
if (PortalHandler.conflictsWithExistingPortal(gate, portalLocation.getTopLeft(), yaw, player)) { if (conflictsWithExistingPortal(gate, portalLocation.getTopLeft(), yaw, player)) {
return null; 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;
}
} }

View File

@ -86,11 +86,11 @@ public class PortalHandler {
destinations.add(portal.getName()); destinations.add(portal.getName());
continue; 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())) { if (PermissionHelper.cannotAccessWorld(player, portal.getWorld().getName())) {
continue; continue;
} }
//Visible to this player. //The portal is visible to the player
if (PermissionHelper.canSeePortal(player, portal)) { if (PermissionHelper.canSeePortal(player, portal)) {
destinations.add(portal.getName()); destinations.add(portal.getName());
} }
@ -170,30 +170,6 @@ public class PortalHandler {
return gate; 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 * Updates the sign and open state of portals pointing at the newly created portal
* *

View File

@ -191,7 +191,7 @@ public class PortalSignDrawer {
*/ */
private void drawFixedSign(Sign sign) { private void drawFixedSign(Sign sign) {
if (portal.getOptions().isRandom()) { if (portal.getOptions().isRandom()) {
setLine(sign, 1, "> " + Stargate.getString("signRandom") + " <"); setLine(sign, 1, ">" + Stargate.getString("signRandom") + "<");
} else { } else {
setLine(sign, 1, ">" + portal.getDestinationName() + "<"); setLine(sign, 1, ">" + portal.getDestinationName() + "<");
} }