CmdReload made more useful by changing how commands that can be disabled are added to the root. You can now get the instance of FCmdRoot, Recheck variable added commands, rebuild brigadierManager, and get the status of each command that can be disabled. CmdDebug now gets the status of variable added commands.
Signed-off-by: DroppingAnvil <dr0pping.4nvi1@gmail.com>
This commit is contained in:
parent
d5645f3b0a
commit
58e43b41cc
@ -13,7 +13,6 @@ import com.massivecraft.factions.cmd.check.WeeWooTask;
|
|||||||
import com.massivecraft.factions.cmd.chest.AntiChestListener;
|
import com.massivecraft.factions.cmd.chest.AntiChestListener;
|
||||||
import com.massivecraft.factions.discord.Discord;
|
import com.massivecraft.factions.discord.Discord;
|
||||||
import com.massivecraft.factions.discord.DiscordListener;
|
import com.massivecraft.factions.discord.DiscordListener;
|
||||||
import com.massivecraft.factions.discord.FactionChatHandler;
|
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.integration.Worldguard;
|
import com.massivecraft.factions.integration.Worldguard;
|
||||||
import com.massivecraft.factions.integration.dynmap.EngineDynmap;
|
import com.massivecraft.factions.integration.dynmap.EngineDynmap;
|
||||||
|
@ -17,13 +17,28 @@ public class CmdDebug extends FCommand {
|
|||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
FactionsPlugin.getInstance().divider();
|
FactionsPlugin.getInstance().divider();
|
||||||
System.out.print("----------Debug Info----------");
|
System.out.print("----------Debug Info----------");
|
||||||
System.out.print("--------Main-------");
|
System.out.print("-------Main-------");
|
||||||
System.out.print("Server Version: " + FactionsPlugin.getInstance().getServer().getVersion());
|
System.out.print("Server Version: " + FactionsPlugin.getInstance().getServer().getVersion());
|
||||||
System.out.print("Server Bukkit Version: " + FactionsPlugin.getInstance().getServer().getBukkitVersion());
|
System.out.print("Server Bukkit Version: " + FactionsPlugin.getInstance().getServer().getBukkitVersion());
|
||||||
System.out.print("SaberFactions Version: " + FactionsPlugin.getInstance().getDescription().getVersion());
|
System.out.print("SaberFactions Version: " + FactionsPlugin.getInstance().getDescription().getVersion());
|
||||||
System.out.print("Is Beta Version: " + (FactionsPlugin.getInstance().getDescription().getFullName().contains("BETA") ? "True" : "False"));
|
System.out.print("Is Beta Version: " + (FactionsPlugin.getInstance().getDescription().getFullName().contains("BETA") ? "True" : "False"));
|
||||||
System.out.print("Players Online: " + Bukkit.getOnlinePlayers().size());
|
System.out.print("Players Online: " + Bukkit.getOnlinePlayers().size());
|
||||||
System.out.print("------End Main-----");
|
System.out.print("------Command------");
|
||||||
|
System.out.print("Discord Commands: " + FCmdRoot.instance.discordEnabled);
|
||||||
|
System.out.print("Check/WeeWoo Commands: " + FCmdRoot.instance.checkEnabled);
|
||||||
|
System.out.print("Mission Command: " + FCmdRoot.instance.missionsEnabled);
|
||||||
|
System.out.print("Shop Command: " + FCmdRoot.instance.fShopEnabled);
|
||||||
|
System.out.print("Inventory See Command: " + FCmdRoot.instance.invSeeEnabled);
|
||||||
|
System.out.print("Points Command: " + FCmdRoot.instance.fPointsEnabled);
|
||||||
|
System.out.print("Alts Command: " + FCmdRoot.instance.fAltsEnabled);
|
||||||
|
System.out.print("Grace Command: " + FCmdRoot.instance.fGraceEnabled);
|
||||||
|
System.out.print("Focus Command: " + FCmdRoot.instance.fFocusEnabled);
|
||||||
|
System.out.print("Fly Command: " + FCmdRoot.instance.fFlyEnabled);
|
||||||
|
System.out.print("PayPal Commands: " + FCmdRoot.instance.fPayPalEnabled);
|
||||||
|
System.out.print("Inspect Command: " + FCmdRoot.instance.coreProtectEnabled);
|
||||||
|
System.out.print("Internal FTOP Command: " + FCmdRoot.instance.internalFTOPEnabled);
|
||||||
|
System.out.print("----End Command----");
|
||||||
|
System.out.print("-----End Main-----");
|
||||||
System.out.print("------Discord------");
|
System.out.print("------Discord------");
|
||||||
System.out.print("Discord Integration enabled in config: " + Discord.confUseDiscord);
|
System.out.print("Discord Integration enabled in config: " + Discord.confUseDiscord);
|
||||||
System.out.print("Discord Integration enabled: " + Discord.useDiscord);
|
System.out.print("Discord Integration enabled: " + Discord.useDiscord);
|
||||||
|
@ -31,7 +31,7 @@ public class CmdReload extends FCommand {
|
|||||||
FactionsPlugin.getInstance().loadLang();
|
FactionsPlugin.getInstance().loadLang();
|
||||||
|
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
|
||||||
FactionsPlugin.getInstance().factionsFlight = true;
|
FactionsPlugin.getInstance().factionsFlight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,9 @@ public class CmdReload extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Discord.setupDiscord();
|
Discord.setupDiscord();
|
||||||
|
//Recheck if commands should truly be disabled and rebuild.
|
||||||
|
FCmdRoot.instance.addVariableCommands();
|
||||||
|
FCmdRoot.instance.rebuild();
|
||||||
long timeReload = (System.currentTimeMillis() - timeInitStart);
|
long timeReload = (System.currentTimeMillis() - timeInitStart);
|
||||||
|
|
||||||
context.msg(TL.COMMAND_RELOAD_TIME, timeReload);
|
context.msg(TL.COMMAND_RELOAD_TIME, timeReload);
|
||||||
|
@ -42,8 +42,8 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public static FCmdRoot instance;
|
||||||
public BrigadierManager brigadierManager;
|
public BrigadierManager brigadierManager;
|
||||||
|
|
||||||
public CmdAdmin cmdAdmin = new CmdAdmin();
|
public CmdAdmin cmdAdmin = new CmdAdmin();
|
||||||
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
|
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
|
||||||
public CmdBoom cmdBoom = new CmdBoom();
|
public CmdBoom cmdBoom = new CmdBoom();
|
||||||
@ -160,9 +160,24 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
public CmdSetGuild cmdSetGuild = new CmdSetGuild();
|
public CmdSetGuild cmdSetGuild = new CmdSetGuild();
|
||||||
public CmdDiscord cmdDiscord = new CmdDiscord();
|
public CmdDiscord cmdDiscord = new CmdDiscord();
|
||||||
public CmdDebug cmdDebug = new CmdDebug();
|
public CmdDebug cmdDebug = new CmdDebug();
|
||||||
|
//Variables to know if we already setup certain sub commands
|
||||||
|
public Boolean discordEnabled = false;
|
||||||
|
public Boolean checkEnabled = false;
|
||||||
|
public Boolean missionsEnabled = false;
|
||||||
|
public Boolean fShopEnabled = false;
|
||||||
|
public Boolean invSeeEnabled = false;
|
||||||
|
public Boolean fPointsEnabled = false;
|
||||||
|
public Boolean fAltsEnabled = false;
|
||||||
|
public Boolean fGraceEnabled = false;
|
||||||
|
public Boolean fFocusEnabled = false;
|
||||||
|
public Boolean fFlyEnabled = false;
|
||||||
|
public Boolean fPayPalEnabled = false;
|
||||||
|
public Boolean coreProtectEnabled = false;
|
||||||
|
public Boolean internalFTOPEnabled = false;
|
||||||
|
|
||||||
public FCmdRoot() {
|
public FCmdRoot() {
|
||||||
super();
|
super();
|
||||||
|
instance = this;
|
||||||
|
|
||||||
if (CommodoreProvider.isSupported()) brigadierManager = new BrigadierManager();
|
if (CommodoreProvider.isSupported()) brigadierManager = new BrigadierManager();
|
||||||
|
|
||||||
@ -273,75 +288,88 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
this.addSubCommand(this.cmdViewChest);
|
this.addSubCommand(this.cmdViewChest);
|
||||||
this.addSubCommand(this.cmdConvertConfig);
|
this.addSubCommand(this.cmdConvertConfig);
|
||||||
this.addSubCommand(this.cmdSpawnerLock);
|
this.addSubCommand(this.cmdSpawnerLock);
|
||||||
|
addVariableCommands();
|
||||||
|
if (CommodoreProvider.isSupported()) brigadierManager.build();
|
||||||
|
}
|
||||||
|
|
||||||
if(Conf.useDiscordSystem){
|
/**
|
||||||
this.addSubCommand(this.cmdInviteBot);
|
* Add sub commands to the root if they are enabled
|
||||||
this.addSubCommand(this.cmdSetGuild);
|
*/
|
||||||
|
public void addVariableCommands() {
|
||||||
|
//Discord
|
||||||
|
if (Conf.useDiscordSystem && !discordEnabled) {
|
||||||
|
this.addSubCommand(this.cmdInviteBot);
|
||||||
|
this.addSubCommand(this.cmdSetGuild);
|
||||||
|
this.addSubCommand(this.cmdSetDiscord);
|
||||||
|
this.addSubCommand(this.cmdSeeDiscord);
|
||||||
|
this.addSubCommand(this.cmdDiscord);
|
||||||
|
discordEnabled = true;
|
||||||
|
}
|
||||||
|
//PayPal
|
||||||
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled", false) && !fPayPalEnabled) {
|
||||||
|
this.addSubCommand(this.cmdPaypalSet);
|
||||||
|
this.addSubCommand(this.cmdPaypalSee);
|
||||||
|
fPayPalEnabled = true;
|
||||||
}
|
}
|
||||||
|
//Check
|
||||||
if (Conf.useCheckSystem) {
|
if (Conf.useCheckSystem && !checkEnabled) {
|
||||||
this.addSubCommand(this.cmdCheck);
|
this.addSubCommand(this.cmdCheck);
|
||||||
this.addSubCommand(this.cmdWeeWoo);
|
this.addSubCommand(this.cmdWeeWoo);
|
||||||
|
checkEnabled = true;
|
||||||
}
|
}
|
||||||
|
//CoreProtect
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("Missions-Enabled")) {
|
if (Bukkit.getServer().getPluginManager().getPlugin("CoreProtect") != null && !coreProtectEnabled) {
|
||||||
this.addSubCommand(this.cmdMissions);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled")) {
|
|
||||||
this.addSubCommand(this.cmdShop);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled")) {
|
|
||||||
this.addSubCommand(this.cmdInventorySee);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-points.Enabled")) {
|
|
||||||
this.addSubCommand(this.cmdPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-alts.Enabled")) {
|
|
||||||
this.addSubCommand(this.cmdAlts);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-grace.Enabled")) {
|
|
||||||
this.addSubCommand(this.cmdGrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (Bukkit.getServer().getPluginManager().getPlugin("CoreProtect") != null) {
|
|
||||||
FactionsPlugin.getInstance().log("Found CoreProtect, enabling Inspect");
|
FactionsPlugin.getInstance().log("Found CoreProtect, enabling Inspect");
|
||||||
this.addSubCommand(this.cmdInspect);
|
this.addSubCommand(this.cmdInspect);
|
||||||
|
coreProtectEnabled = true;
|
||||||
} else {
|
} else {
|
||||||
FactionsPlugin.getInstance().log("CoreProtect not found, disabling Inspect");
|
FactionsPlugin.getInstance().log("CoreProtect not found, disabling Inspect");
|
||||||
}
|
}
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) {
|
//FTOP
|
||||||
addSubCommand(this.cmdFocus);
|
if ((Bukkit.getServer().getPluginManager().getPlugin("FactionsTop") != null || Bukkit.getServer().getPluginManager().getPlugin("SavageFTOP") != null || Bukkit.getServer().getPluginManager().getPlugin("SaberFTOP") != null) && !internalFTOPEnabled) {
|
||||||
}
|
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
|
|
||||||
this.addSubCommand(this.cmdFly);
|
|
||||||
}
|
|
||||||
if (Bukkit.getServer().getPluginManager().getPlugin("FactionsTop") != null || Bukkit.getServer().getPluginManager().getPlugin("SavageFTOP") != null || Bukkit.getServer().getPluginManager().getPlugin("SaberFTOP") != null) {
|
|
||||||
FactionsPlugin.getInstance().log(Level.INFO, "Found FactionsTop plugin. Disabling our own /f top command.");
|
FactionsPlugin.getInstance().log(Level.INFO, "Found FactionsTop plugin. Disabling our own /f top command.");
|
||||||
} else {
|
} else {
|
||||||
FactionsPlugin.getInstance().log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc.");
|
FactionsPlugin.getInstance().log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc.");
|
||||||
this.addSubCommand(this.cmdTop);
|
this.addSubCommand(this.cmdTop);
|
||||||
|
internalFTOPEnabled = true;
|
||||||
}
|
}
|
||||||
|
//Other
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("fdiscord.Enabled")) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("Missions-Enabled", false) && !missionsEnabled) {
|
||||||
this.addSubCommand(this.cmdSetDiscord);
|
this.addSubCommand(this.cmdMissions);
|
||||||
this.addSubCommand(this.cmdSeeDiscord);
|
missionsEnabled = true;
|
||||||
}
|
}
|
||||||
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled", false) && !fShopEnabled) {
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) {
|
this.addSubCommand(this.cmdShop);
|
||||||
this.addSubCommand(this.cmdPaypalSet);
|
fShopEnabled = true;
|
||||||
this.addSubCommand(this.cmdPaypalSee);
|
}
|
||||||
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled", false) && !invSeeEnabled) {
|
||||||
|
this.addSubCommand(this.cmdInventorySee);
|
||||||
|
invSeeEnabled = true;
|
||||||
|
}
|
||||||
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-points.Enabled", false) && !fPointsEnabled) {
|
||||||
|
this.addSubCommand(this.cmdPoints);
|
||||||
|
fPointsEnabled = true;
|
||||||
|
}
|
||||||
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-alts.Enabled", false) && !fAltsEnabled) {
|
||||||
|
this.addSubCommand(this.cmdAlts);
|
||||||
|
fAltsEnabled = true;
|
||||||
|
}
|
||||||
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-grace.Enabled", false) && !fGraceEnabled) {
|
||||||
|
this.addSubCommand(this.cmdGrace);
|
||||||
|
fGraceEnabled = true;
|
||||||
|
}
|
||||||
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled") && !fFocusEnabled) {
|
||||||
|
addSubCommand(this.cmdFocus);
|
||||||
|
fFocusEnabled = true;
|
||||||
|
}
|
||||||
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false) && !fFlyEnabled) {
|
||||||
|
this.addSubCommand(this.cmdFly);
|
||||||
|
fFlyEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommodoreProvider.isSupported()) brigadierManager.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rebuild() {if (CommodoreProvider.isSupported()) brigadierManager.build();}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
context.commandChain.add(this);
|
context.commandChain.add(this);
|
||||||
|
@ -29,7 +29,6 @@ import net.coreprotect.CoreProtect;
|
|||||||
import net.coreprotect.CoreProtectAPI;
|
import net.coreprotect.CoreProtectAPI;
|
||||||
import net.dv8tion.jda.core.entities.Member;
|
import net.dv8tion.jda.core.entities.Member;
|
||||||
import net.dv8tion.jda.core.entities.TextChannel;
|
import net.dv8tion.jda.core.entities.TextChannel;
|
||||||
import net.dv8tion.jda.core.entities.User;
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
Loading…
Reference in New Issue
Block a user