location command fix when UseLocationsInSameWorld is enabled

locations can be used in another world with bypass perm when UseLocationsInSameWorld is enabled
This commit is contained in:
SuperRonanCraft 2023-05-11 23:05:53 -04:00
parent 1e903e447b
commit 671d422683
6 changed files with 13 additions and 3 deletions

View File

@ -125,5 +125,11 @@
<version>1.18.22</version> <version>1.18.22</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>19.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -7,7 +7,7 @@
<groupId>me.SuperRonanCraft</groupId> <groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTP</artifactId> <artifactId>BetterRTP</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>3.6.8-4</version> <version>3.6.8-3-DEVBUILD</version>
<!-- Upload patches to https://repo.ronanplugins.com/#/ --> <!-- Upload patches to https://repo.ronanplugins.com/#/ -->

View File

@ -89,11 +89,13 @@ public class CmdLocation implements RTPCommand, RTPCommandHelpable {
HashMap<String, RTPWorld> locations = new HashMap<>(); HashMap<String, RTPWorld> locations = new HashMap<>();
boolean needPermission = BetterRTP.getInstance().getSettings().isLocationNeedPermission(); boolean needPermission = BetterRTP.getInstance().getSettings().isLocationNeedPermission();
boolean needSameWorld = BetterRTP.getInstance().getSettings().isUseLocationsInSameWorld(); boolean needSameWorld = BetterRTP.getInstance().getSettings().isUseLocationsInSameWorld();
if (needSameWorld)
needSameWorld = !PermissionNode.BYPASS_LOCATION.check(sendi);
for (Map.Entry<String, RTPWorld> location : BetterRTP.getInstance().getRTP().getRTPworldLocations().entrySet()) { for (Map.Entry<String, RTPWorld> location : BetterRTP.getInstance().getRTP().getRTPworldLocations().entrySet()) {
boolean add = true; boolean add = true;
if (needPermission) //Do we need permission to go to this location? if (needPermission) //Do we need permission to go to this location?
add = PermissionCheck.getLocation(sendi, location.getKey()); add = PermissionCheck.getLocation(sendi, location.getKey());
if (add && needSameWorld) //Can be added and needs same world (if not same world, we don't care to check) if (add && needSameWorld) //Can be added and needs same world (if not same world, we don't check)
add = world == null || location.getValue().getWorld().equals(world); add = world == null || location.getValue().getWorld().equals(world);
if (add) //Location can be added to list if (add) //Location can be added to list
locations.put(location.getKey(), location.getValue()); locations.put(location.getKey(), location.getValue());

View File

@ -16,6 +16,7 @@ public enum PermissionNode implements PermissionCheck {
BYPASS_HUNGER("bypass.hunger"), BYPASS_HUNGER("bypass.hunger"),
BYPASS_COOLDOWN("bypass.cooldown"), BYPASS_COOLDOWN("bypass.cooldown"),
BYPASS_DELAY("bypass.delay"), BYPASS_DELAY("bypass.delay"),
BYPASS_LOCATION("bypass.location"), //Ability to bypass `UseLocationsInSameWorld` if enabled in location.yml
RELOAD("reload"), RELOAD("reload"),
SETTINGS("settings"), SETTINGS("settings"),
INFO("info"), INFO("info"),

View File

@ -61,7 +61,7 @@ Settings:
DisableUpdater: false DisableUpdater: false
Logger: Logger:
Enabled: true #Log all things rtp related to the log.log file Enabled: true #Log all things rtp related to the log.log file
LogToConsole: true LogToConsole: false
Format: 'yyyy-MM-dd HH:mm:ss' Format: 'yyyy-MM-dd HH:mm:ss'
Default: Default:

View File

@ -14,6 +14,7 @@ Enabled: false #enable the locations feature
RequirePermission: false #Require players to have `betterrtp.location.<world_name>` RequirePermission: false #Require players to have `betterrtp.location.<world_name>`
UseLocationIfAvailable: true #Will choose a location upon `/rtp` if location(s) is available in the world UseLocationIfAvailable: true #Will choose a location upon `/rtp` if location(s) is available in the world
UseLocationsInSameWorld: true #Will only choose locations in same world rtp'ing in UseLocationsInSameWorld: true #Will only choose locations in same world rtp'ing in
# If UseLocationsInSameWorld is set to true, use `betterrtp.bypass.location` to allow rtp'ing to locations in other worlds
Locations: Locations:
- main_loc: - main_loc: