1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

Default behavior for default jobs command

This commit is contained in:
Zrips 2022-11-15 13:16:17 +02:00
parent fb5a520f1a
commit e4ca78fa57
3 changed files with 1128 additions and 1081 deletions

View File

@ -309,6 +309,10 @@ public final class Jobs extends JavaPlugin {
}
public static GeneralConfigManager getGCManager() {
return getGeneralConfigManager();
}
public static GeneralConfigManager getGeneralConfigManager() {
if (gConfigManager == null)
gConfigManager = new GeneralConfigManager();
return gConfigManager;

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -24,6 +25,7 @@ import com.gamingmesh.jobs.container.Title;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Container.CMIArray;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.Messages.CMIMessages;
@ -55,8 +57,25 @@ public class JobsCommands implements CommandExecutor {
return true;
}
if (args.length == 0)
helpBrake: if (args.length == 0) {
if (!Jobs.getGeneralConfigManager().helpPageBehavior.isEmpty() && sender instanceof Player) {
if (Jobs.getGeneralConfigManager().helpPageBehavior.get(0).equals("browse")) {
args = CMIArray.addLast(args, "browse");
break helpBrake;
}
boolean result = false;
for (String one : Jobs.getGeneralConfigManager().helpPageBehavior) {
one = one.replace("[playerName]", sender.getName());
if (Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one))
result = true;
}
return result;
}
return help(sender, 1);
}
if ((args.length == 1 || args.length == 2) && (args[0].equals("?") || args[0].equalsIgnoreCase("help"))) {
int page = 1;

View File

@ -39,6 +39,7 @@ import com.gamingmesh.jobs.CMILib.CMIEnchantment;
import com.gamingmesh.jobs.container.CurrencyLimit;
import com.gamingmesh.jobs.container.CurrencyType;
import net.Zrips.CMILib.Container.CMIArray;
import net.Zrips.CMILib.Container.CMIList;
import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.FileHandler.ConfigReader;
@ -50,6 +51,8 @@ public class GeneralConfigManager {
public List<Integer> BroadcastingLevelUpLevels = new ArrayList<>();
public List<String> DisabledWorldsList = new ArrayList<>();
public List<String> helpPageBehavior = new ArrayList<>();
public final Map<CMIMaterial, Map<Enchantment, Integer>> whiteListedItems = new HashMap<>();
private final Map<CurrencyType, CurrencyLimit> currencyLimitUse = new HashMap<>();
@ -1041,6 +1044,27 @@ public class GeneralConfigManager {
c.addComment("JobsGUI.SkipAmount", "Defines by how many slots we need to skip after group");
JobsGUISkipAmount = c.get("JobsGUI.SkipAmount", 2);
c.addComment("Commands.Jobs", "What should happen when performing clean /jobs command", "Options:",
"Default - behaves like before and will open jobs help page with list of commands player can access",
"Browse - will open jobs browse GUI where player can check existing jobs and their actions",
"Last option is to define command you want to perform, use [playerName] variable to replace it with players name who performed it. Multiple commands can be provided too. Commands will be performed from console.");
helpPageBehavior.clear();
if (c.getC().isList("Commands.Jobs")) {
helpPageBehavior.addAll(c.get("Commands.Jobs", Arrays.asList("Default")));
} else {
helpPageBehavior.add(c.get("Commands.Jobs", "Default"));
}
if (!helpPageBehavior.isEmpty()) {
if (helpPageBehavior.size() == 1 && helpPageBehavior.get(0).equalsIgnoreCase("Default"))
helpPageBehavior.clear();
if (helpPageBehavior.size() == 1 && helpPageBehavior.get(0).equalsIgnoreCase("Browse")) {
helpPageBehavior.clear();
helpPageBehavior.add("browse");
}
}
c.addComment("Commands.PageRow.JobsTop.AmountToShow", "Defines amount of players to be shown in one page for /jobs top & /jobs gtop");
JobsTopAmount = c.get("Commands.PageRow.JobsTop.AmountToShow", 15);
c.addComment("Commands.PageRow.Placeholders.AmountToShow", "Defines amount of placeholders to be shown in one page for /jobs placeholders");