mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 09:37:54 +01:00
Removed duplicated code: PlanProxyCommand
PlanBungeeCommand and PlanVelocityCommand were the same, and should stay the same, with exception of the name. So new module that defines the name of the main command was created and now the duplicate code could be removed.
This commit is contained in:
parent
9eaa350758
commit
bdd4d4c333
@ -17,7 +17,7 @@
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.command.PlanBungeeCommand;
|
||||
import com.djrapitops.plan.command.PlanProxyCommand;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
@ -67,7 +67,7 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
||||
logger.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
|
||||
onDisable();
|
||||
}
|
||||
PlanBungeeCommand command = component.planCommand();
|
||||
PlanProxyCommand command = component.planCommand();
|
||||
command.registerCommands();
|
||||
registerCommand("planbungee", command);
|
||||
}
|
||||
|
@ -16,8 +16,9 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.command.PlanBungeeCommand;
|
||||
import com.djrapitops.plan.command.PlanProxyCommand;
|
||||
import com.djrapitops.plan.modules.*;
|
||||
import com.djrapitops.plan.modules.bungee.BungeeCommandModule;
|
||||
import com.djrapitops.plan.modules.bungee.BungeePlanModule;
|
||||
import com.djrapitops.plan.modules.bungee.BungeeServerPropertiesModule;
|
||||
import com.djrapitops.plan.modules.bungee.BungeeSuperClassBindingModule;
|
||||
@ -36,6 +37,7 @@ import javax.inject.Singleton;
|
||||
@Singleton
|
||||
@Component(modules = {
|
||||
BungeePlanModule.class,
|
||||
BungeeCommandModule.class,
|
||||
SuperClassBindingModule.class,
|
||||
SystemObjectProvidingModule.class,
|
||||
APFModule.class,
|
||||
@ -47,7 +49,7 @@ import javax.inject.Singleton;
|
||||
})
|
||||
public interface PlanBungeeComponent {
|
||||
|
||||
PlanBungeeCommand planCommand();
|
||||
PlanProxyCommand planCommand();
|
||||
|
||||
PlanSystem system();
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.modules.bungee;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
@Module
|
||||
public class BungeeCommandModule {
|
||||
|
||||
@Provides
|
||||
@Named("mainCommandName")
|
||||
String provideMainCommandName() {
|
||||
return "planbungee";
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ package com.djrapitops.plan.modules.bungee;
|
||||
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.command.PlanBungeeCommand;
|
||||
import com.djrapitops.plan.command.PlanProxyCommand;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
@ -38,5 +38,5 @@ public interface BungeePlanModule {
|
||||
|
||||
@Binds
|
||||
@Named("mainCommand")
|
||||
CommandNode bindMainCommand(PlanBungeeCommand command);
|
||||
CommandNode bindMainCommand(PlanProxyCommand command);
|
||||
}
|
@ -30,6 +30,7 @@ import com.djrapitops.plugin.command.TreeCmdNode;
|
||||
import dagger.Lazy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
@ -41,7 +42,7 @@ import javax.inject.Singleton;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Singleton
|
||||
public class PlanBungeeCommand extends TreeCmdNode {
|
||||
public class PlanProxyCommand extends TreeCmdNode {
|
||||
|
||||
private final NetworkCommand networkCommand;
|
||||
private final ListServersCommand listServersCommand;
|
||||
@ -58,7 +59,8 @@ public class PlanBungeeCommand extends TreeCmdNode {
|
||||
private boolean commandsRegistered;
|
||||
|
||||
@Inject
|
||||
public PlanBungeeCommand(
|
||||
public PlanProxyCommand(
|
||||
@Named("mainCommandName") String mainCommandName,
|
||||
ColorScheme colorScheme,
|
||||
Locale locale,
|
||||
// Group 1
|
||||
@ -76,7 +78,7 @@ public class PlanBungeeCommand extends TreeCmdNode {
|
||||
ReloadCommand reloadCommand,
|
||||
DisableCommand disableCommand
|
||||
) {
|
||||
super("planbungee", Permissions.MANAGE.getPermission(), CommandType.CONSOLE, null);
|
||||
super(mainCommandName, Permissions.MANAGE.getPermission(), CommandType.CONSOLE, null);
|
||||
this.uninstalledCommand = uninstalledCommand;
|
||||
|
||||
commandsRegistered = false;
|
@ -17,7 +17,7 @@
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.command.PlanVelocityCommand;
|
||||
import com.djrapitops.plan.command.PlanProxyCommand;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
@ -93,7 +93,7 @@ public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
|
||||
logger.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
|
||||
onDisable();
|
||||
}
|
||||
PlanVelocityCommand command = component.planCommand();
|
||||
PlanProxyCommand command = component.planCommand();
|
||||
command.registerCommands();
|
||||
registerCommand("planvelocity", command);
|
||||
}
|
||||
|
@ -16,8 +16,9 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.command.PlanVelocityCommand;
|
||||
import com.djrapitops.plan.command.PlanProxyCommand;
|
||||
import com.djrapitops.plan.modules.*;
|
||||
import com.djrapitops.plan.modules.velocity.VelocityCommandModule;
|
||||
import com.djrapitops.plan.modules.velocity.VelocityPlanModule;
|
||||
import com.djrapitops.plan.modules.velocity.VelocityServerPropertiesModule;
|
||||
import com.djrapitops.plan.modules.velocity.VelocitySuperClassBindingModule;
|
||||
@ -36,6 +37,7 @@ import javax.inject.Singleton;
|
||||
@Singleton
|
||||
@Component(modules = {
|
||||
VelocityPlanModule.class,
|
||||
VelocityCommandModule.class,
|
||||
SuperClassBindingModule.class,
|
||||
SystemObjectProvidingModule.class,
|
||||
APFModule.class,
|
||||
@ -47,7 +49,7 @@ import javax.inject.Singleton;
|
||||
})
|
||||
public interface PlanVelocityComponent {
|
||||
|
||||
PlanVelocityCommand planCommand();
|
||||
PlanProxyCommand planCommand();
|
||||
|
||||
PlanSystem system();
|
||||
|
||||
|
@ -1,125 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.command;
|
||||
|
||||
import com.djrapitops.plan.command.commands.*;
|
||||
import com.djrapitops.plan.command.commands.manage.ManageConDebugCommand;
|
||||
import com.djrapitops.plan.command.commands.manage.ManageRawDataCommand;
|
||||
import com.djrapitops.plan.command.commands.manage.ManageUninstalledCommand;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.TreeCmdNode;
|
||||
import dagger.Lazy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* TreeCommand for the /plan command, and all subcommands.
|
||||
* <p>
|
||||
* Uses the Abstract Plugin Framework for easier command management.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Singleton
|
||||
public class PlanVelocityCommand extends TreeCmdNode {
|
||||
|
||||
private final NetworkCommand networkCommand;
|
||||
private final ListServersCommand listServersCommand;
|
||||
private final ListPlayersCommand listPlayersCommand;
|
||||
private final RegisterCommand registerCommand;
|
||||
private final Lazy<WebUserCommand> webUserCommand;
|
||||
private final ManageConDebugCommand conDebugCommand;
|
||||
private final ManageRawDataCommand rawDataCommand;
|
||||
private final BungeeSetupToggleCommand setupToggleCommand;
|
||||
private final ReloadCommand reloadCommand;
|
||||
private final DisableCommand disableCommand;
|
||||
private final ManageUninstalledCommand uninstalledCommand;
|
||||
|
||||
private boolean commandsRegistered;
|
||||
|
||||
@Inject
|
||||
public PlanVelocityCommand(
|
||||
ColorScheme colorScheme,
|
||||
Locale locale,
|
||||
// Group 1
|
||||
NetworkCommand networkCommand,
|
||||
ListServersCommand listServersCommand,
|
||||
ListPlayersCommand listPlayersCommand,
|
||||
// Group 2
|
||||
RegisterCommand registerCommand,
|
||||
Lazy<WebUserCommand> webUserCommand,
|
||||
// Group 3
|
||||
ManageConDebugCommand conDebugCommand,
|
||||
ManageRawDataCommand rawDataCommand,
|
||||
BungeeSetupToggleCommand setupToggleCommand,
|
||||
ManageUninstalledCommand uninstalledCommand,
|
||||
ReloadCommand reloadCommand,
|
||||
DisableCommand disableCommand
|
||||
) {
|
||||
super("planvelocity", Permissions.MANAGE.getPermission(), CommandType.CONSOLE, null);
|
||||
this.uninstalledCommand = uninstalledCommand;
|
||||
|
||||
commandsRegistered = false;
|
||||
|
||||
this.networkCommand = networkCommand;
|
||||
this.listServersCommand = listServersCommand;
|
||||
this.listPlayersCommand = listPlayersCommand;
|
||||
this.registerCommand = registerCommand;
|
||||
this.webUserCommand = webUserCommand;
|
||||
this.conDebugCommand = conDebugCommand;
|
||||
this.rawDataCommand = rawDataCommand;
|
||||
this.setupToggleCommand = setupToggleCommand;
|
||||
this.reloadCommand = reloadCommand;
|
||||
this.disableCommand = disableCommand;
|
||||
|
||||
getHelpCommand().setPermission(Permissions.MANAGE.getPermission());
|
||||
setColorScheme(colorScheme);
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.PLAN));
|
||||
}
|
||||
|
||||
public void registerCommands() {
|
||||
if (commandsRegistered) {
|
||||
return;
|
||||
}
|
||||
|
||||
CommandNode[] analyticsGroup = {
|
||||
networkCommand,
|
||||
listServersCommand,
|
||||
listPlayersCommand
|
||||
};
|
||||
CommandNode[] webGroup = {
|
||||
registerCommand,
|
||||
webUserCommand.get()
|
||||
};
|
||||
CommandNode[] manageGroup = {
|
||||
conDebugCommand,
|
||||
rawDataCommand,
|
||||
setupToggleCommand,
|
||||
uninstalledCommand,
|
||||
reloadCommand,
|
||||
disableCommand
|
||||
};
|
||||
setNodeGroups(analyticsGroup, webGroup, manageGroup);
|
||||
commandsRegistered = true;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.modules.velocity;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
@Module
|
||||
public class VelocityCommandModule {
|
||||
|
||||
@Provides
|
||||
@Named("mainCommandName")
|
||||
String provideMainCommandName() {
|
||||
return "planvelocity";
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ package com.djrapitops.plan.modules.velocity;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.PlanVelocity;
|
||||
import com.djrapitops.plan.command.PlanVelocityCommand;
|
||||
import com.djrapitops.plan.command.PlanProxyCommand;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
@ -38,5 +38,5 @@ public interface VelocityPlanModule {
|
||||
|
||||
@Binds
|
||||
@Named("mainCommand")
|
||||
CommandNode provideMainCommand(PlanVelocityCommand command);
|
||||
CommandNode provideMainCommand(PlanProxyCommand command);
|
||||
}
|
Loading…
Reference in New Issue
Block a user