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