mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-07-04 13:01:32 +00:00
Allow /pp toggle [on|off]
This commit is contained in:
parent
6a4a068051
commit
e3bb724934
1 changed files with 24 additions and 8 deletions
|
@ -5,24 +5,40 @@ import dev.esophose.playerparticles.api.PlayerParticlesAPI;
|
|||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
public class ToggleCommandModule implements CommandModule {
|
||||
|
||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
boolean canSee = pplayer.canSeeParticles();
|
||||
PlayerParticlesAPI.getInstance().togglePlayerParticleVisibility(pplayer.getPlayer(), canSee);
|
||||
|
||||
if (canSee) {
|
||||
localeManager.sendMessage(pplayer, "toggle-off");
|
||||
} else {
|
||||
if (args.length == 0) {
|
||||
boolean particlesHidden = pplayer.canSeeParticles();
|
||||
PlayerParticlesAPI.getInstance().togglePlayerParticleVisibility(pplayer.getPlayer(), particlesHidden);
|
||||
|
||||
if (particlesHidden) {
|
||||
localeManager.sendMessage(pplayer, "toggle-off");
|
||||
} else {
|
||||
localeManager.sendMessage(pplayer, "toggle-on");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("on")) {
|
||||
PlayerParticlesAPI.getInstance().togglePlayerParticleVisibility(pplayer.getPlayer(), false);
|
||||
localeManager.sendMessage(pplayer, "toggle-on");
|
||||
} else {
|
||||
PlayerParticlesAPI.getInstance().togglePlayerParticleVisibility(pplayer.getPlayer(), true);
|
||||
localeManager.sendMessage(pplayer, "toggle-off");
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
|
||||
return new ArrayList<>();
|
||||
List<String> completions = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
List<String> possibilities = Arrays.asList("on", "off");
|
||||
StringUtil.copyPartialMatches(args[0], possibilities, completions);
|
||||
}
|
||||
return completions;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -34,7 +50,7 @@ public class ToggleCommandModule implements CommandModule {
|
|||
}
|
||||
|
||||
public String getArguments() {
|
||||
return "";
|
||||
return "[on|off]";
|
||||
}
|
||||
|
||||
public boolean requiresEffectsAndStyles() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue