mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 09:05:47 +00:00
new locations permission blueprint
This commit is contained in:
parent
934b246615
commit
b56696cb1b
@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CmdLocation implements RTPCommand, RTPCommandHelpable {
|
||||
|
||||
@ -26,7 +27,7 @@ public class CmdLocation implements RTPCommand, RTPCommandHelpable {
|
||||
public void execute(CommandSender sendi, String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (sendi instanceof Player) {
|
||||
for (String location_name : getLocations().keySet()) {
|
||||
for (String location_name : getLocations(sendi).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));
|
||||
@ -39,7 +40,7 @@ public class CmdLocation implements RTPCommand, RTPCommandHelpable {
|
||||
} else if (args.length == 3 && BetterRTP.getInstance().getPerms().getRtpOther(sendi)) {
|
||||
Player p = Bukkit.getPlayer(args[2]);
|
||||
if (p != null && p.isOnline()) {
|
||||
for (String location_name : getLocations().keySet()) {
|
||||
for (String location_name : getLocations(sendi).keySet()) {
|
||||
if (location_name.equalsIgnoreCase(args[1].toLowerCase())) {
|
||||
HelperRTP.tp(p, sendi, null, null, RTP_TYPE.COMMAND, false, false, (WorldLocations) getLocations().get(location_name));
|
||||
return;
|
||||
@ -57,7 +58,7 @@ 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().keySet())
|
||||
for (String location_name : getLocations(sendi).keySet())
|
||||
if (location_name.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
list.add(location_name);
|
||||
} else if (args.length == 3 && BetterRTP.getInstance().getPerms().getRtpOther(sendi)) {
|
||||
@ -76,10 +77,19 @@ public class CmdLocation implements RTPCommand, RTPCommandHelpable {
|
||||
BetterRTP.getInstance().getText().getUsageLocation(sendi, label);
|
||||
}
|
||||
|
||||
private HashMap<String, RTPWorld> getLocations() {
|
||||
public static HashMap<String, RTPWorld> getLocations() {
|
||||
return BetterRTP.getInstance().getRTP().worldLocations;
|
||||
}
|
||||
|
||||
//Get locations a player has access to
|
||||
public static HashMap<String, RTPWorld> getLocations(CommandSender sendi) {
|
||||
HashMap<String, RTPWorld> locations = new HashMap<>();
|
||||
for (Map.Entry<String, RTPWorld> location : getLocations().entrySet())
|
||||
if (BetterRTP.getInstance().getPerms().getLocation(sendi, location.getKey()))
|
||||
locations.put(location.getKey(), location.getValue());
|
||||
return locations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return BetterRTP.getInstance().getText().getHelpLocation();
|
||||
|
@ -95,6 +95,10 @@ public class Permissions {
|
||||
return checkPerm(pre + "location", sendi);
|
||||
}
|
||||
|
||||
public boolean getLocation(CommandSender sendi, String location) {
|
||||
return checkPerm(pre + "location." + location, sendi);
|
||||
}
|
||||
|
||||
public boolean getPermissionGroup(CommandSender sendi, String group) {
|
||||
return checkPerm(pre + "group." + group, sendi);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.helpers;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.types.CmdLocation;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.CooldownData;
|
||||
@ -39,6 +40,10 @@ public class HelperRTP {
|
||||
if (!getPl().getPerms().getBypassDelay(player)) //Can bypass?
|
||||
delay = true;
|
||||
//player.sendMessage("Cooldown applies: " + cooldownApplies(sendi, player));
|
||||
if (getPl().getSettings().isUseLocationIfAvailable() && !CmdLocation.getLocations().isEmpty()) {
|
||||
|
||||
}
|
||||
|
||||
RTPSetupInformation setup_info = new RTPSetupInformation(world, sendi, player, true,
|
||||
biomes, delay, rtpType, locations, !ignoreCooldown && cooldownApplies(sendi, player)); //ignore cooldown or else
|
||||
getPl().getRTP().start(setup_info);
|
||||
|
@ -16,7 +16,9 @@ public class Settings {
|
||||
@Getter private int preloadRadius; //Amount of chunks to load around a safe rtp location (clamped (0 - 16))
|
||||
//Dependencies
|
||||
private final SoftDepends depends = new SoftDepends();
|
||||
public boolean protocolLibSounds;
|
||||
@Getter private boolean protocolLibSounds;
|
||||
@Getter private boolean useLocationIfAvailable;
|
||||
@Getter private boolean locationNeedPermission;
|
||||
|
||||
public void load() { //Load Settings
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||
@ -29,6 +31,8 @@ public class Settings {
|
||||
preloadRadius = config.getInt("Settings.PreloadRadius");
|
||||
statusMessages = config.getBoolean("Settings.StatusMessages");
|
||||
protocolLibSounds = FileBasics.FILETYPE.EFFECTS.getBoolean("Sounds.ProtocolLibSound");
|
||||
useLocationIfAvailable = FileBasics.FILETYPE.LOCATIONS.getBoolean("UseLocationIfAvailable");
|
||||
locationNeedPermission = FileBasics.FILETYPE.LOCATIONS.getBoolean("RequirePermission");
|
||||
depends.load();
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,19 @@
|
||||
#Locations where rtp will center upon
|
||||
#Format:
|
||||
# LOCATION_NAME:
|
||||
# World: world
|
||||
# CenterX: 100
|
||||
# CenterY: 150
|
||||
# MaxRadius: 100
|
||||
# MinRadius: 5
|
||||
# - LOCATION_NAME:
|
||||
# World: world
|
||||
# CenterX: 100
|
||||
# CenterY: 150
|
||||
# MaxRadius: 100
|
||||
# MinRadius: 5
|
||||
|
||||
Enabled: false
|
||||
Enabled: false #enable the locations feature
|
||||
RequirePermission: false #Require players to have `betterrtp.location.<world_name>`
|
||||
UseLocationIfAvailable: false #Will choose a location upon `/rtp` if location(s) is available in the world
|
||||
|
||||
Locations:
|
||||
- main_loc:
|
||||
World: world
|
||||
World: world_name
|
||||
CenterX: 100
|
||||
CenterZ: 150
|
||||
MaxRadius: 100 #optional
|
||||
|
@ -28,12 +28,20 @@ permissions:
|
||||
description: RTP to specific biomes
|
||||
betterrtp.sign:
|
||||
description: Ability to create an RTP sign
|
||||
#Locations
|
||||
betterrtp.location:
|
||||
description: Ability to use the location command
|
||||
betterrtp.location.*:
|
||||
description: Ability to use all locations if permissions are enabled in locations.yml
|
||||
default: op
|
||||
#Bypasses
|
||||
betterrtp.bypass.cooldown:
|
||||
description: Bypass cooldowns
|
||||
betterrtp.bypass.delay:
|
||||
description: Bypass delays
|
||||
betterrtp.bypass.economy:
|
||||
description: Bypass economy
|
||||
#Reload
|
||||
betterrtp.reload:
|
||||
description: Reload the config
|
||||
default: op
|
||||
|
Loading…
x
Reference in New Issue
Block a user