mirror of
https://github.com/Phoenix616/RandomTeleport.git
synced 2024-11-22 10:36:00 +01:00
Fix cooldown, y location calculator and teleport target
This commit is contained in:
parent
f0f014cc23
commit
5f73ccc955
@ -308,12 +308,13 @@ public class RandomTeleport extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cooldown > 0) {
|
if (cooldown > 0 && cooldown < searcher.getCooldown()) {
|
||||||
sendMessage(searcher.getTargets(), "error.cooldown", "cooldown_text", cooldown + "s");
|
sendMessage(searcher.getTargets(), "error.cooldown", "cooldown_text", (searcher.getCooldown() - cooldown) + "s");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
sendMessage(searcher.getTargets(), "search", "worldname", searcher.getCenter().getWorld().getName());
|
sendMessage(searcher.getTargets(), "search", "worldname", searcher.getCenter().getWorld().getName());
|
||||||
searcher.search().thenApply(targetLoc -> {
|
searcher.search().thenApply(targetLoc -> {
|
||||||
|
targetLoc.add(0, 1, 0);
|
||||||
searcher.getTargets().forEach(e -> {
|
searcher.getTargets().forEach(e -> {
|
||||||
cooldowns.put(searcher.getId(), e.getUniqueId(), new AbstractMap.SimpleImmutableEntry<>(System.currentTimeMillis(), searcher.getCooldown()));
|
cooldowns.put(searcher.getId(), e.getUniqueId(), new AbstractMap.SimpleImmutableEntry<>(System.currentTimeMillis(), searcher.getCooldown()));
|
||||||
e.teleport(targetLoc);
|
e.teleport(targetLoc);
|
||||||
|
@ -31,8 +31,14 @@ public class HeightValidator extends LocationValidator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validate(RandomSearcher searcher, Location location) {
|
public boolean validate(RandomSearcher searcher, Location location) {
|
||||||
location.setY(location.getWorld().getHighestBlockYAt(location));
|
Block block = location.getWorld().getHighestBlockAt(location);
|
||||||
Block block = location.getBlock();
|
while (block.isEmpty()) {
|
||||||
return !block.isEmpty() && !block.getRelative(BlockFace.UP).getType().isSolid() && !block.getRelative(BlockFace.UP, 2).getType().isSolid();
|
block = block.getRelative(BlockFace.DOWN);
|
||||||
|
if (block == null || block.getY() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
location.setY(block.getY());
|
||||||
|
return !block.getRelative(BlockFace.UP).getType().isSolid() && !block.getRelative(BlockFace.UP, 2).getType().isSolid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user