Altered tab completion to include "stop" argument.

Included the isPlayerOrbited check inside the scheduler to fix premature checking
This commit is contained in:
Sczptor 2024-02-04 09:19:31 +00:00
parent 7d1698c1da
commit 6a85428724
2 changed files with 16 additions and 5 deletions

View File

@ -13,6 +13,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.UUID;
@ -61,7 +62,15 @@ public class OrbitCommand extends PlexCommand
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
{
return PlexUtils.getPlayerNameList();
}
else if (args.length == 2 && silentCheckPermission(sender, this.getPermission()))
{
return Collections.singletonList("stop");
}
return ImmutableList.of();
}
private void startOrbiting(Player player, int strength)

View File

@ -20,12 +20,14 @@ public class OrbitEffectListener extends PlexListener
{
if ((event.getAction() == EntityPotionEffectEvent.Action.CLEARED || event.getAction() == EntityPotionEffectEvent.Action.REMOVED)
&& event.getModifiedType() == PotionEffectType.LEVITATION)
{
Bukkit.getScheduler().runTaskLater(Plex.get(), () ->
{
if (OrbitCommand.isPlayerOrbited(player.getUniqueId()))
{
Bukkit.getScheduler().runTaskLater(Plex.get(), () ->
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, Integer.MAX_VALUE, 100, false, false)), 2);
}
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, Integer.MAX_VALUE, 100, false, false));
}
}, 2);
}
}
}