1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00
Jobs/com/gamingmesh/jobs/commands/list/toggle.java
2016-03-30 16:42:36 +03:00

73 lines
2.5 KiB
Java

package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.JobsPlugin;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ChatColor;
public class toggle implements Cmd {
@JobCommand(1000)
public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame"));
return false;
}
if (args.length != 1) {
Jobs.getCommandManager().sendUsage(sender, "toggle");
return true;
}
String PlayerName = sender.getName();
if (PlayerName == null || !args[0].equalsIgnoreCase("bossbar") && !args[0].equalsIgnoreCase("actionbar")) {
Jobs.getCommandManager().sendUsage(sender, "toggle");
return true;
}
if (args[0].equalsIgnoreCase("actionbar"))
if (Jobs.getActionbarToggleList().containsKey(PlayerName))
if (Jobs.getActionbarToggleList().get(PlayerName)) {
Jobs.getActionbarToggleList().put(PlayerName, false);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.off"));
} else {
Jobs.getActionbarToggleList().put(PlayerName, true);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
else {
Jobs.getActionbarToggleList().put(PlayerName, true);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
if (args[0].equalsIgnoreCase("bossbar"))
if (Jobs.getBossBarToggleList().containsKey(PlayerName))
if (Jobs.getBossBarToggleList().get(PlayerName)) {
Jobs.getBossBarToggleList().put(PlayerName, false);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.off"));
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(PlayerName);
if (jPlayer != null)
jPlayer.hideBossBars();
} else {
Jobs.getBossBarToggleList().put(PlayerName, true);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
else {
Jobs.getBossBarToggleList().put(PlayerName, true);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.on"));
}
return true;
}
}