Skip to content

Commit

Permalink
Added the ability to disable visitors sign from being a requirement t…
Browse files Browse the repository at this point in the history
…o visit islands
  • Loading branch information
OmerBenGera committed Aug 12, 2022
1 parent 6f926bb commit f8f6566
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
Expand Up @@ -836,6 +836,12 @@ interface IslandRoles {

interface VisitorsSign {

/**
* Whether a visitors sign is required for others to visit islands.
* Config-path: visitors-sign.required-for-visit
*/
boolean isRequiredForVisit();

/**
* The line that determines if the sign is used as a visitors home location.
* Config-path: visitors-sign.line
Expand Down
Expand Up @@ -62,7 +62,9 @@ public void execute(SuperiorSkyblockPlugin plugin, CommandSender sender, String[

SuperiorPlayer superiorPlayer = plugin.getPlayers().getSuperiorPlayer(sender);

Location visitLocation = targetIsland.getVisitorsLocation(null /* unused */);
Location visitLocation = plugin.getSettings().getVisitorsSign().isRequiredForVisit() ?
targetIsland.getVisitorsLocation(null /* unused */) :
targetIsland.getIslandHome(plugin.getSettings().getWorlds().getDefaultWorld());

if (visitLocation == null) {
Message.INVALID_VISIT_LOCATION.send(sender);
Expand All @@ -87,8 +89,9 @@ public List<String> tabComplete(SuperiorSkyblockPlugin plugin, CommandSender sen
SuperiorPlayer superiorPlayer = plugin.getPlayers().getSuperiorPlayer(sender);
return args.length == 2 ? CommandTabCompletes.getOnlinePlayersWithIslands(plugin, args[1],
plugin.getSettings().isTabCompleteHideVanished(),
(onlinePlayer, onlineIsland) -> onlineIsland != null && (onlineIsland.getVisitorsLocation(null /* unused */) != null ||
superiorPlayer.hasBypassModeEnabled()) && (!onlineIsland.isLocked() ||
(onlinePlayer, onlineIsland) -> onlineIsland != null && (
(!plugin.getSettings().getVisitorsSign().isRequiredForVisit() || onlineIsland.getVisitorsLocation(null /* unused */) != null) ||
superiorPlayer.hasBypassModeEnabled()) && (!onlineIsland.isLocked() ||
onlineIsland.hasPermission(superiorPlayer, IslandPrivileges.CLOSE_BYPASS))) : Collections.emptyList();
}

Expand Down
Expand Up @@ -89,6 +89,7 @@ public class SettingsContainer {
public final long calcInterval;
public final String signWarpLine;
public final List<String> signWarp;
public final boolean visitorsSignRequiredForVisit;
public final String visitorsSignLine;
public final String visitorsSignActive;
public final String visitorsSignInactive;
Expand Down Expand Up @@ -300,6 +301,7 @@ else if (sections.length == 3)
signWarp = Formatters.formatList(config.getStringList("sign-warp"), Formatters.COLOR_FORMATTER);
while (signWarp.size() < 4)
signWarp.add("");
visitorsSignRequiredForVisit = config.getBoolean("visitors-sign.required-for-visit", true);
visitorsSignLine = config.getString("visitors-sign.line", "[Welcome]");
visitorsSignActive = Formatters.COLOR_FORMATTER.format(config.getString("visitors-sign.active", "&a[Welcome]"));
visitorsSignInactive = Formatters.COLOR_FORMATTER.format(config.getString("visitors-sign.inactive", "&c[Welcome]"));
Expand Down
Expand Up @@ -11,6 +11,11 @@ public VisitorsSignSection(SettingsContainer container) {
this.container = container;
}

@Override
public boolean isRequiredForVisit() {
return this.container.visitorsSignRequiredForVisit;
}

@Override
public String getLine() {
return this.container.visitorsSignLine;
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Expand Up @@ -270,6 +270,9 @@ sign-warp:

# All settings related to the visitors sign.
visitors-sign:
# Whether a visitors sign is required for others to visit islands.
# If set to false, visitors will be teleported to the regular island home when using `/is visit`
required-for-visit: true
# Set the line to create the visitors sign.
line: '[Welcome]'
# The line that will be displayed when the sign is active.
Expand Down

0 comments on commit f8f6566

Please sign in to comment.