locations useworldborder fix + command

This commit is contained in:
SuperRonanCraft 2021-04-01 19:01:11 -04:00
parent 6d8abaf420
commit ed0d5f589b
5 changed files with 46 additions and 23 deletions

View File

@ -6,6 +6,7 @@ import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE; import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_CommandEvent; import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_CommandEvent;
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics; import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
import me.SuperRonanCraft.BetterRTP.references.worlds.WorldLocations;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -141,7 +142,13 @@ public class Commands {
this.tp(player, sendi, world, biomes, rtpType, false, false); this.tp(player, sendi, world, biomes, rtpType, false, false);
} }
public void tp(Player player, CommandSender sendi, String world, List<String> biomes, RTP_TYPE rtpType, boolean ignoreCooldown, boolean ignoreDelay) { public void tp(Player player, CommandSender sendi, String world, List<String> biomes, RTP_TYPE rtpType,
boolean ignoreCooldown, boolean ignoreDelay) {
this.tp(player, sendi, world, biomes, rtpType, ignoreCooldown, ignoreDelay, null);
}
public void tp(Player player, CommandSender sendi, String world, List<String> biomes, RTP_TYPE rtpType,
boolean ignoreCooldown, boolean ignoreDelay, WorldLocations locations) {
if (checkRTPing(player, sendi)) { //Is RTP'ing if (checkRTPing(player, sendi)) { //Is RTP'ing
if (ignoreCooldown || checkCooldown(sendi, player)) { //Is Cooling down if (ignoreCooldown || checkCooldown(sendi, player)) { //Is Cooling down
boolean delay = false; boolean delay = false;
@ -149,7 +156,7 @@ public class Commands {
if (pl.getSettings().delayEnabled && delayTimer > 0) //Delay enabled? if (pl.getSettings().delayEnabled && delayTimer > 0) //Delay enabled?
if (!pl.getPerms().getBypassDelay(player)) //Can bypass? if (!pl.getPerms().getBypassDelay(player)) //Can bypass?
delay = true; delay = true;
RTPSetupInformation setup_info = new RTPSetupInformation(world, sendi, player, true, biomes, delay, rtpType, null); RTPSetupInformation setup_info = new RTPSetupInformation(world, sendi, player, true, biomes, delay, rtpType, locations);
pl.getRTP().start(setup_info); pl.getRTP().start(setup_info);
} }
} }

View File

@ -26,15 +26,18 @@ public class CmdLocation implements RTPCommand, RTPCommandHelpable {
//rtp location <location name> //rtp location <location name>
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) {
for (String location_name : getLocations().keySet()) { if (sendi instanceof Player) {
if (location_name.equalsIgnoreCase(args[1].toLowerCase())) { for (String location_name : getLocations().keySet()) {
//LOCATION RTP CODE if (location_name.equalsIgnoreCase(args[1].toLowerCase())) {
//********************************** Player p = (Player) sendi;
//********************************** BetterRTP.getInstance().getCmd().tp(p, sendi, null, null, RTP_TYPE.COMMAND,
return; false, false, (WorldLocations) getLocations().get(location_name));
return;
}
} }
} usage(sendi, label);
usage(sendi, label); } else
sendi.sendMessage("Console is not able to execute this command! Try '/rtp help'");
} else } else
usage(sendi, label); usage(sendi, label);
} }

View File

@ -211,6 +211,14 @@ public class RTP {
Player p = setup_info.player; Player p = setup_info.player;
CommandSender sendi = setup_info.sender; CommandSender sendi = setup_info.sender;
// Locations
if (setup_info.location != null) {
WorldLocations location = setup_info.location;
world_name = location.getWorld().getName();
setup_info.world = world_name;
setup_info.biomes = location.getBiomes();
}
// Check overrides // Check overrides
if (world_name == null) { if (world_name == null) {
world_name = p.getWorld().getName(); world_name = p.getWorld().getName();

View File

@ -1,6 +1,7 @@
package me.SuperRonanCraft.BetterRTP.player.rtp; package me.SuperRonanCraft.BetterRTP.player.rtp;
import me.SuperRonanCraft.BetterRTP.references.worlds.WorldLocations; import me.SuperRonanCraft.BetterRTP.references.worlds.WorldLocations;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -18,18 +19,7 @@ public class RTPSetupInformation {
public RTP_TYPE rtp_type; public RTP_TYPE rtp_type;
public RTPSetupInformation(String world, CommandSender sender, Player player, boolean personalized) { public RTPSetupInformation(String world, CommandSender sender, Player player, boolean personalized) {
this.world = world; this(world, sender, player, personalized, null, false, null, null);
this.sender = sender;
this.player = player;
this.personalized = personalized;
}
public RTPSetupInformation(String world, CommandSender sender, Player player, boolean personalized, List<String> biomes) {
this.world = world;
this.sender = sender;
this.player = player;
this.personalized = personalized;
this.biomes = biomes;
} }
public RTPSetupInformation(String world, CommandSender sender, Player player, boolean personalized, List<String> biomes, public RTPSetupInformation(String world, CommandSender sender, Player player, boolean personalized, List<String> biomes,
@ -42,5 +32,11 @@ public class RTPSetupInformation {
this.delay = delay; this.delay = delay;
this.rtp_type = rtp_type; this.rtp_type = rtp_type;
this.location = location; this.location = location;
if (this.world == null) {
if (player != null)
this.world = player.getWorld().getName();
else if (this.location != null)
this.world = this.location.getWorld().getName();
}
} }
} }

View File

@ -94,6 +94,15 @@ public class WorldLocations implements RTPWorld, RTPWorld_Defaulted {
} }
} }
} }
if (test.get("UseWorldBorder") != null) {
if (test.get("UseWorldBorder").getClass() == Boolean.class) {
try {
this.useWorldborder = Boolean.parseBoolean(test.get("UseWorldBorder").toString());
} catch (Exception e) {
//No UseWorldBorder
}
}
}
} }
} }
} }
@ -109,7 +118,7 @@ public class WorldLocations implements RTPWorld, RTPWorld_Defaulted {
@Override @Override
public boolean getUseWorldborder() { public boolean getUseWorldborder() {
return false;//useWorldborder; return useWorldborder;
} }
@Override @Override