mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-02-16 02:21:06 +00:00
locations take over target world
This commit is contained in:
@@ -28,14 +28,13 @@ public class CmdLocation implements RTPCommand, RTPCommandHelpable {
|
||||
//rtp location <location name> [player]
|
||||
public void execute(CommandSender sendi, String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (sendi instanceof Player) {
|
||||
for (String location_name : getLocations(sendi, null).keySet()) {
|
||||
if (sendi instanceof Player) {
|
||||
Player p = (Player) sendi;
|
||||
for (String location_name : getLocations(sendi, p.getWorld()).keySet())
|
||||
if (location_name.equalsIgnoreCase(args[1].toLowerCase())) {
|
||||
Player p = (Player) sendi;
|
||||
HelperRTP.tp(p, sendi, null, null, RTP_TYPE.COMMAND, false, false, (WorldLocations) getLocations().get(location_name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
usage(sendi, label);
|
||||
} else
|
||||
sendi.sendMessage("Console is not able to execute this command! Try '/rtp help'");
|
||||
@@ -60,7 +59,8 @@ public class CmdLocation implements RTPCommand, RTPCommandHelpable {
|
||||
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (args.length == 2) {
|
||||
for (String location_name : getLocations(sendi, null).keySet())
|
||||
Player p = (Player) sendi;
|
||||
for (String location_name : getLocations(sendi, p.getWorld()).keySet())
|
||||
if (location_name.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
list.add(location_name);
|
||||
} else if (args.length == 3 && PermissionNode.RTP_OTHER.check(sendi)) {
|
||||
@@ -85,16 +85,17 @@ public class CmdLocation implements RTPCommand, RTPCommandHelpable {
|
||||
|
||||
//Get locations a player has access to
|
||||
public static HashMap<String, RTPWorld> getLocations(CommandSender sendi, @Nullable World world) {
|
||||
if (BetterRTP.getInstance().getSettings().isLocationNeedPermission()) {
|
||||
HashMap<String, RTPWorld> locations = new HashMap<>();
|
||||
for (Map.Entry<String, RTPWorld> location : getLocations().entrySet())
|
||||
if (PermissionNode.getLocation(sendi, location.getKey())) {
|
||||
if (world == null || location.getValue().getWorld().equals(world))
|
||||
locations.put(location.getKey(), location.getValue());
|
||||
}
|
||||
return locations;
|
||||
} else
|
||||
return getLocations();
|
||||
HashMap<String, RTPWorld> locations = new HashMap<>();
|
||||
for (Map.Entry<String, RTPWorld> location : getLocations().entrySet()) {
|
||||
boolean add = false;
|
||||
if (BetterRTP.getInstance().getSettings().isLocationNeedPermission())
|
||||
add = PermissionNode.getLocation(sendi, location.getKey());
|
||||
if (BetterRTP.getInstance().getSettings().isUseLocationsInSameWorld())
|
||||
add = world == null || location.getValue().getWorld().equals(world);
|
||||
if (add)
|
||||
locations.put(location.getKey(), location.getValue());
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -75,7 +75,11 @@ public class RTP {
|
||||
|
||||
//Random Location
|
||||
if (setup_info.getLocation() == null && BetterRTP.getInstance().getSettings().isUseLocationIfAvailable()) {
|
||||
setup_info.setLocation(HelperRTP.getRandomLocation(setup_info.getSender(), setup_info.getWorld()));
|
||||
WorldLocations worldLocation = HelperRTP.getRandomLocation(setup_info.getSender(), setup_info.getWorld());
|
||||
if (worldLocation != null) {
|
||||
setup_info.setLocation(worldLocation);
|
||||
setup_info.setWorld(worldLocation.getWorld());
|
||||
}
|
||||
if (setup_info.getLocation() == null && BetterRTP.getInstance().getSettings().isDebug())
|
||||
WarningHandler.warn(WarningHandler.WARNING.USELOCATION_ENABLED_NO_LOCATION_AVAILABLE,
|
||||
"This is not an error! UseLocationIfAvailable is set to `true`, but no location was found for "
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Settings {
|
||||
@Getter private boolean protocolLibSounds;
|
||||
@Getter private boolean useLocationIfAvailable;
|
||||
@Getter private boolean locationNeedPermission;
|
||||
@Getter private boolean locationOnlyAllowInWorld;
|
||||
@Getter private boolean useLocationsInSameWorld;
|
||||
@Getter private boolean permissionGroupEnabled;
|
||||
@Getter private boolean queueEnabled;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Settings {
|
||||
protocolLibSounds = FileBasics.FILETYPE.EFFECTS.getBoolean("Sounds.ProtocolLibSound");
|
||||
useLocationIfAvailable = FileBasics.FILETYPE.LOCATIONS.getBoolean("UseLocationIfAvailable");
|
||||
locationNeedPermission = FileBasics.FILETYPE.LOCATIONS.getBoolean("RequirePermission");
|
||||
locationOnlyAllowInWorld = FileBasics.FILETYPE.LOCATIONS.getBoolean("OnlyAllowInWorld");
|
||||
useLocationsInSameWorld = FileBasics.FILETYPE.LOCATIONS.getBoolean("UseLocationsInSameWorld");
|
||||
depends.load();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
# CenterY: 150
|
||||
# MaxRadius: 100
|
||||
# MinRadius: 5
|
||||
# Shape: square
|
||||
# MinY: 0
|
||||
# MaxY: 320
|
||||
|
||||
Enabled: false #enable the locations feature
|
||||
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
|
||||
UseLocationsInSameWorld: true #Will only choose locations in same world rtp'ing in
|
||||
|
||||
Locations:
|
||||
- main_loc:
|
||||
|
||||
Reference in New Issue
Block a user