[Merge] Module split (#786)

* Moved project files to 'common'-module

This is done so that refactoring into multiple smaller modules is easier
as the IDE will not attempt to move tests incorrectly when moving things
between different modules

* Created 'bukkit' module

Following classes were removed during the operation:
- BukkitServerInfo (Renamed to ServerServerInfo)
- SpongeServerInfo (could use ServerServerInfo)
- Hastebin (not viable on every platform, unused)
- HastebinTest
- MockPlayers (unused, bukkit specific)

Changes to classes:
- Renamed Importer to BukkitImporter (contained bukkit related impl.)
- Extracted Importer interface from BukkitImporter
- Turned BukkitPlanModule and BukkitClassBindingModule to interfaces by
  using @Binds annotation
- Added Status class since PlayersOnlineListener had a boolean,
  that stated if kicks were counted.

This commit completes split partially and was not pushed on commit.

* Created 'sponge' module

Changes to classes:
- Turned ServerSuperClassBindingModule, SuperClassBindingModule,
  SpongePlanModule and SpongeClassBindingModule to interfaces by
  using @Binds annotation
- Renamed SystemObjectBindingModule to SystemObjectProvidingModule
- Removed sponge related calls in ServerProperties
- Made EmptyImportSystem injectable

This commit completes split partially and was not pushed on commit.

* Changed shade configuration

Further tweaks required.

* Created 'bungeecord' module

Changes to classes:
- Removed use of BungeePingTimerTask in VelocityTaskSystem
- Removed use of RedisBungee in VelocityServerProperties
- Fixed bukkit command.commands.RegisterCommandFilter package

Changes to project structure:
- Dependency versions now in main pom via dependencyManagement
- Repositories now defined in main pom

* Created 'velocity' module

Changes to classes:
- Made RawDataResponse use Gson via reflection since it is no longer
  available in dependencies of 'common' module

* Created 'plugin' module

This module is for creating a single deployment artifact and testing of
system interactions.

Fixes to tests:
- Reflection no longer fails to initialize if Bukkit.getServer() is null
- PingCountTimerBukkit no longer fails to be created if Reflection fails
- Removed unnecessary @AfterClass from H2Test
- Jar resource path fixes to Mocker

* Shading configuration

org.slf4j classes are relocated in 'common', 'bukkit' & 'bungeecord'.
In 'sponge' & 'velocity' they are not relocated, allowing injection
as plugin logger, while using slf4j-nop for HikariCP logging.

This allows single release artifact.

* Removed 'Icon' from .gitignore

* Attempt to fix test resources

Because all jar resources are located in 'common', an attempt to fetch
them is made to common/target/Plan-common.jar, which for some reason
is a bad path.

This attempts to remedy that by creating a temporary file from an
InputStream, read with Class#getResourceAsStream

Ignored HTTPSWebServerAuthTest as the certificate path was invalid for
some reason.
This commit is contained in:
Risto Lahtela 2018-11-11 12:55:09 +02:00 committed by GitHub
parent b9ae627388
commit ebaffcab5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
801 changed files with 1955 additions and 2143 deletions

3
.gitignore vendored
View File

@ -120,9 +120,6 @@ nbactions.xml
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*

99
Plan/bukkit/pom.xml Normal file
View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>Plan</artifactId>
<groupId>com.djrapitops</groupId>
<version>4.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Plan-bukkit</artifactId>
<build>
<defaultGoal>clean package install</defaultGoal>
<finalName>${project.artifactId}-${project.parent.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>com.djrapitops:AbstractPluginFramework-bukkit</include>
<include>org.bstats:bstats-bukkit</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.djrapitops.plan.utilities.metrics</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>plan.org.slf4j</shadedPattern>
</relocation>
</relocations>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency> <!-- Plan Common classes -->
<groupId>com.djrapitops</groupId>
<artifactId>Plan-common</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency> <!-- Plan Common test classes -->
<groupId>com.djrapitops</groupId>
<artifactId>Plan-common</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency> <!-- Bukkit part of Abstract Plugin Framework -->
<groupId>com.djrapitops</groupId>
<artifactId>AbstractPluginFramework-bukkit</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency> <!-- Metrics -->
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
</dependency>
<dependency> <!-- Paper API -->
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <!-- Spigot API -->
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <!-- Bukkit API -->
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -14,9 +14,8 @@
* 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.utilities.metrics;
package com.djrapitops.plan;
import com.djrapitops.plan.Plan;
import com.djrapitops.plugin.api.Check;
import org.bstats.bukkit.Metrics;

View File

@ -18,11 +18,11 @@ package com.djrapitops.plan;
import com.djrapitops.plan.api.exceptions.EnableException;
import com.djrapitops.plan.command.PlanCommand;
import com.djrapitops.plan.command.commands.RegisterCommandFilter;
import com.djrapitops.plan.system.PlanSystem;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.PluginLang;
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
import com.djrapitops.plan.utilities.metrics.BStatsBukkit;
import com.djrapitops.plugin.BukkitPlugin;
import com.djrapitops.plugin.benchmarking.Benchmark;
import com.djrapitops.plugin.command.ColorScheme;
@ -73,6 +73,7 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
PlanCommand command = component.planCommand();
command.registerCommands();
registerCommand("plan", command);
new RegisterCommandFilter().registerFilter();
}
@Override

View File

@ -17,14 +17,10 @@
package com.djrapitops.plan;
import com.djrapitops.plan.command.PlanCommand;
import com.djrapitops.plan.modules.APFModule;
import com.djrapitops.plan.modules.FilesModule;
import com.djrapitops.plan.modules.SuperClassBindingModule;
import com.djrapitops.plan.modules.SystemObjectBindingModule;
import com.djrapitops.plan.modules.plugin.BukkitPlanModule;
import com.djrapitops.plan.modules.server.ServerSuperClassBindingModule;
import com.djrapitops.plan.modules.server.bukkit.BukkitServerPropertiesModule;
import com.djrapitops.plan.modules.server.bukkit.BukkitSuperClassBindingModule;
import com.djrapitops.plan.modules.*;
import com.djrapitops.plan.modules.bukkit.BukkitPlanModule;
import com.djrapitops.plan.modules.bukkit.BukkitServerPropertiesModule;
import com.djrapitops.plan.modules.bukkit.BukkitSuperClassBindingModule;
import com.djrapitops.plan.system.PlanSystem;
import com.djrapitops.pluginbridge.plan.PluginBridgeModule;
import dagger.BindsInstance;
@ -41,7 +37,7 @@ import javax.inject.Singleton;
@Component(modules = {
BukkitPlanModule.class,
SuperClassBindingModule.class,
SystemObjectBindingModule.class,
SystemObjectProvidingModule.class,
APFModule.class,
FilesModule.class,
BukkitServerPropertiesModule.class,

View File

@ -14,17 +14,16 @@
* 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.plugin;
package com.djrapitops.plan.modules.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.command.PlanCommand;
import com.djrapitops.plugin.command.CommandNode;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import javax.inject.Named;
import javax.inject.Singleton;
/**
* Dagger module for binding Plan instance.
@ -32,18 +31,12 @@ import javax.inject.Singleton;
* @author Rsl1122
*/
@Module
public class BukkitPlanModule {
public interface BukkitPlanModule {
@Provides
@Singleton
PlanPlugin providePlanPlugin(Plan plugin) {
return plugin;
}
@Binds
PlanPlugin bindPlanPlugin(Plan plugin);
@Provides
@Singleton
@Binds
@Named("mainCommand")
CommandNode provideMainCommand(PlanCommand command) {
return command;
}
CommandNode bindMainCommand(PlanCommand command);
}

View File

@ -14,7 +14,7 @@
* 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.server.bukkit;
package com.djrapitops.plan.modules.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.system.info.server.properties.BukkitServerProperties;

View File

@ -14,24 +14,22 @@
* 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.server.bukkit;
package com.djrapitops.plan.modules.bukkit;
import com.djrapitops.plan.system.database.BukkitDBSystem;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.importing.BukkitImportSystem;
import com.djrapitops.plan.system.importing.ImportSystem;
import com.djrapitops.plan.system.info.server.BukkitServerInfo;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.info.server.ServerServerInfo;
import com.djrapitops.plan.system.listeners.BukkitListenerSystem;
import com.djrapitops.plan.system.listeners.ListenerSystem;
import com.djrapitops.plan.system.settings.config.BukkitConfigSystem;
import com.djrapitops.plan.system.settings.config.ConfigSystem;
import com.djrapitops.plan.system.tasks.BukkitTaskSystem;
import com.djrapitops.plan.system.tasks.TaskSystem;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import javax.inject.Singleton;
/**
* Module for binding Bukkit specific classes to the interface implementations.
@ -39,42 +37,24 @@ import javax.inject.Singleton;
* @author Rsl1122
*/
@Module
public class BukkitSuperClassBindingModule {
public interface BukkitSuperClassBindingModule {
@Provides
@Singleton
ServerInfo provideBukkitServerInfo(BukkitServerInfo bukkitServerInfo) {
return bukkitServerInfo;
}
@Binds
ServerInfo bindBukkitServerInfo(ServerServerInfo serverServerInfo);
@Provides
@Singleton
DBSystem provideBukkitDatabaseSystem(BukkitDBSystem dbSystem) {
return dbSystem;
}
@Binds
DBSystem bindBukkitDatabaseSystem(BukkitDBSystem dbSystem);
@Provides
@Singleton
ConfigSystem provideBukkitConfigSystem(BukkitConfigSystem bukkitConfigSystem) {
return bukkitConfigSystem;
}
@Binds
ConfigSystem bindBukkitConfigSystem(BukkitConfigSystem bukkitConfigSystem);
@Provides
@Singleton
TaskSystem provideBukkitTaskSystem(BukkitTaskSystem bukkitTaskSystem) {
return bukkitTaskSystem;
}
@Binds
TaskSystem bindBukkitTaskSystem(BukkitTaskSystem bukkitTaskSystem);
@Provides
@Singleton
ListenerSystem provideBukkitListenerSystem(BukkitListenerSystem bukkitListenerSystem) {
return bukkitListenerSystem;
}
@Binds
ListenerSystem bindBukkitListenerSystem(BukkitListenerSystem bukkitListenerSystem);
@Provides
@Singleton
ImportSystem provideImportSsytem(BukkitImportSystem bukkitImportSystem) {
return bukkitImportSystem;
}
@Binds
ImportSystem bindImportSsytem(BukkitImportSystem bukkitImportSystem);
}

View File

@ -48,16 +48,15 @@ import java.util.stream.Collectors;
* @author Fuzzlemann
* @since 4.0.0
*/
public abstract class Importer {
public abstract class BukkitImporter implements Importer {
protected final Supplier<UUID> serverUUID;
private final GeolocationCache geolocationCache;
private final DBSystem dbSystem;
protected final Supplier<UUID> serverUUID;
private final String name;
private final Plan plugin;
protected Importer(
protected BukkitImporter(
Plan plugin,
GeolocationCache geolocationCache,
DBSystem dbSystem,
@ -77,6 +76,7 @@ public abstract class Importer {
return new ArrayList<>();
}
@Override
public String getName() {
return name;
}
@ -85,6 +85,7 @@ public abstract class Importer {
public abstract List<UserImportData> getUserImportData();
@Override
public final void processImport() {
ExecutorService service = Executors.newCachedThreadPool();

View File

@ -37,7 +37,7 @@ import java.util.Set;
* @since 4.0.0
*/
@Singleton
public class OfflinePlayerImporter extends Importer {
public class OfflinePlayerImporter extends BukkitImporter {
@Inject
public OfflinePlayerImporter(

View File

@ -18,6 +18,7 @@ package com.djrapitops.plan.system.listeners;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.system.listeners.bukkit.*;
import com.djrapitops.plan.system.status.Status;
import org.bukkit.event.HandlerList;
import javax.inject.Inject;
@ -26,6 +27,7 @@ public class BukkitListenerSystem extends ListenerSystem {
private final Plan plugin;
private final Status status;
private final PlayerOnlineListener playerOnlineListener;
private final ChatListener chatListener;
private final GameModeChangeListener gamemodeChangeListener;
@ -36,6 +38,7 @@ public class BukkitListenerSystem extends ListenerSystem {
@Inject
public BukkitListenerSystem(Plan plugin,
Status status,
PlayerOnlineListener playerOnlineListener,
ChatListener chatListener,
GameModeChangeListener gamemodeChangeListener,
@ -45,6 +48,7 @@ public class BukkitListenerSystem extends ListenerSystem {
AFKListener afkListener
) {
this.plugin = plugin;
this.status = status;
this.playerOnlineListener = playerOnlineListener;
this.chatListener = chatListener;
@ -66,7 +70,7 @@ public class BukkitListenerSystem extends ListenerSystem {
deathEventListener,
afkListener
);
PlayerOnlineListener.setCountKicks(true);
status.setCountKicks(true);
}
@Override

View File

@ -23,6 +23,7 @@ import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.processing.processors.Processors;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.system.status.Status;
import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.task.RunnableFactory;
@ -47,20 +48,15 @@ import java.util.UUID;
*/
public class PlayerOnlineListener implements Listener {
private static boolean countKicks = true;
private final PlanConfig config;
private final Processors processors;
private final Processing processing;
private final ServerInfo serverInfo;
private final SessionCache sessionCache;
private final ErrorHandler errorHandler;
private final Status status;
private final RunnableFactory runnableFactory;
public static void setCountKicks(boolean value) {
countKicks = value;
}
@Inject
public PlayerOnlineListener(
PlanConfig config,
@ -68,6 +64,7 @@ public class PlayerOnlineListener implements Listener {
Processing processing,
ServerInfo serverInfo,
SessionCache sessionCache,
Status status,
RunnableFactory runnableFactory,
ErrorHandler errorHandler
) {
@ -76,6 +73,7 @@ public class PlayerOnlineListener implements Listener {
this.processing = processing;
this.serverInfo = serverInfo;
this.sessionCache = sessionCache;
this.status = status;
this.runnableFactory = runnableFactory;
this.errorHandler = errorHandler;
}
@ -104,7 +102,7 @@ public class PlayerOnlineListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event) {
try {
if (!countKicks || event.isCancelled()) {
if (!status.areKicksCounted() || event.isCancelled()) {
return;
}
UUID uuid = event.getPlayer().getUniqueId();

View File

@ -20,11 +20,11 @@ import com.djrapitops.plan.Plan;
import com.djrapitops.plan.ShutdownHook;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.system.tasks.bukkit.BukkitTPSCountTimer;
import com.djrapitops.plan.system.tasks.bukkit.PaperTPSCountTimer;
import com.djrapitops.plan.system.tasks.bukkit.PingCountTimerBukkit;
import com.djrapitops.plan.system.tasks.server.BootAnalysisTask;
import com.djrapitops.plan.system.tasks.server.PeriodicAnalysisTask;
import com.djrapitops.plan.system.tasks.server.bukkit.BukkitTPSCountTimer;
import com.djrapitops.plan.system.tasks.server.bukkit.PaperTPSCountTimer;
import com.djrapitops.plan.system.tasks.server.bukkit.PingCountTimerBukkit;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.task.RunnableFactory;

View File

@ -14,7 +14,7 @@
* 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.system.tasks.server.bukkit;
package com.djrapitops.plan.system.tasks.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.TPS;

View File

@ -14,7 +14,7 @@
* 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.system.tasks.server.bukkit;
package com.djrapitops.plan.system.tasks.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.TPS;

View File

@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.djrapitops.plan.system.tasks.server.bukkit;
package com.djrapitops.plan.system.tasks.bukkit;
import com.djrapitops.plan.data.store.objects.DateObj;
import com.djrapitops.plan.system.processing.Processing;
@ -76,11 +76,12 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
MethodHandle localHandle = null;
MethodHandle localPing = null;
if (!PING_METHOD_AVAILABLE) {
Class<?> craftPlayerClass = Reflection.getCraftBukkitClass("entity.CraftPlayer");
Class<?> entityPlayer = Reflection.getMinecraftClass("EntityPlayer");
Lookup lookup = MethodHandles.publicLookup();
try {
Class<?> craftPlayerClass = Reflection.getCraftBukkitClass("entity.CraftPlayer");
Class<?> entityPlayer = Reflection.getMinecraftClass("EntityPlayer");
Lookup lookup = MethodHandles.publicLookup();
Method getHandleMethod = craftPlayerClass.getDeclaredMethod("getHandle");
localHandle = lookup.unreflect(getHandleMethod);
@ -88,9 +89,14 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
} catch (NoSuchMethodException | IllegalAccessException | NoSuchFieldException reflectiveEx) {
Logger.getGlobal().log(
Level.WARNING,
"Reflective exception in static initializer of Plan PingCountTimer",
"Plan: Reflective exception in static initializer of PingCountTimer",
reflectiveEx
);
} catch (IllegalArgumentException e) {
Logger.getGlobal().log(
Level.WARNING,
"Plan: No Ping method handle found - Ping will not be recorded."
);
}
}

View File

@ -24,6 +24,7 @@
package com.djrapitops.plan.utilities.java;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@ -43,7 +44,7 @@ import java.util.regex.Pattern;
public final class Reflection {
// Deduce the net.minecraft.server.v* package
private static final String OBC_PREFIX = Bukkit.getServer().getClass().getPackage().getName();
private static final String OBC_PREFIX = getOBCPrefix();
private static final String NMS_PREFIX = OBC_PREFIX.replace("org.bukkit.craftbukkit", "net.minecraft.server");
private static final String VERSION = OBC_PREFIX.replace("org.bukkit.craftbukkit", "").replace(".", "");
// Variable replacement
@ -53,6 +54,11 @@ public final class Reflection {
// Seal class
}
private static String getOBCPrefix() {
Server server = Bukkit.getServer();
return server != null ? server.getClass().getPackage().getName() : Server.class.getPackage().getName();
}
/**
* Retrieve a field accessor for a specific field type and name.
*

View File

@ -1,5 +1,6 @@
package com.djrapitops.plan.system.listeners.bukkit;
package com.djrapitops.plan.system.listeners;
import com.djrapitops.plan.system.listeners.bukkit.AFKListener;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plugin.logging.console.TestPluginLogger;
@ -54,7 +55,7 @@ public class AFKListenerTest {
private Player mockPlayer(Collection<Boolean> calls) {
Player player = Mockito.mock(Player.class);
doReturn(TestConstants.PLAYER_ONE_UUID).when(player).getUniqueId();
Mockito.doReturn(TestConstants.PLAYER_ONE_UUID).when(player).getUniqueId();
doAnswer(perm -> {
calls.add(true);
return true;

View File

@ -61,7 +61,7 @@ public class PlanBukkitMocker extends Mocker {
ErrorHandler consoleErrorLogger = new ConsoleErrorLogger(testPluginLogger);
Timings timings = new Timings(debugLogger);
doReturn(testLogger).when(planMock).getLogger();
Mockito.doReturn(testLogger).when(planMock).getLogger();
doReturn(runnableFactory).when(planMock).getRunnableFactory();
doReturn(testPluginLogger).when(planMock).getPluginLogger();
doReturn(debugLogger).when(planMock).getDebugLogger();
@ -105,7 +105,7 @@ public class PlanBukkitMocker extends Mocker {
doReturn(25565).when(serverMock).getPort();
doReturn("1.12.2").when(serverMock).getVersion();
doReturn("32423").when(serverMock).getBukkitVersion();
doReturn(TestConstants.BUKKIT_MAX_PLAYERS).when(serverMock).getMaxPlayers();
Mockito.doReturn(TestConstants.BUKKIT_MAX_PLAYERS).when(serverMock).getMaxPlayers();
ConsoleCommandSender sender = Mockito.mock(ConsoleCommandSender.class);
doReturn(sender).when(serverMock).getConsoleSender();

90
Plan/bungeecord/pom.xml Normal file
View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>Plan</artifactId>
<groupId>com.djrapitops</groupId>
<version>4.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Plan-bungeecord</artifactId>
<build>
<defaultGoal>clean package install</defaultGoal>
<finalName>${project.artifactId}-${project.parent.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>com.djrapitops:AbstractPluginFramework-bungeecord</include>
<include>org.bstats:bstats-bungeecord</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.djrapitops.plan.utilities.metrics</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>plan.org.slf4j</shadedPattern>
</relocation>
</relocations>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency> <!-- Plan Common classes -->
<groupId>com.djrapitops</groupId>
<artifactId>Plan-common</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency> <!-- Plan Common test classes -->
<groupId>com.djrapitops</groupId>
<artifactId>Plan-common</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.djrapitops</groupId>
<artifactId>AbstractPluginFramework-bungeecord</artifactId>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bungeecord</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -14,9 +14,8 @@
* 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.utilities.metrics;
package com.djrapitops.plan;
import com.djrapitops.plan.PlanBungee;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import org.bstats.bungeecord.Metrics;

View File

@ -22,7 +22,6 @@ import com.djrapitops.plan.system.PlanSystem;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.PluginLang;
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
import com.djrapitops.plan.utilities.metrics.BStatsBungee;
import com.djrapitops.plugin.BungeePlugin;
import com.djrapitops.plugin.command.ColorScheme;
import com.djrapitops.plugin.logging.L;

View File

@ -17,14 +17,10 @@
package com.djrapitops.plan;
import com.djrapitops.plan.command.PlanBungeeCommand;
import com.djrapitops.plan.modules.APFModule;
import com.djrapitops.plan.modules.FilesModule;
import com.djrapitops.plan.modules.SuperClassBindingModule;
import com.djrapitops.plan.modules.SystemObjectBindingModule;
import com.djrapitops.plan.modules.plugin.BungeePlanModule;
import com.djrapitops.plan.modules.proxy.ProxySuperClassBindingModule;
import com.djrapitops.plan.modules.proxy.bungee.BungeeServerPropertiesModule;
import com.djrapitops.plan.modules.proxy.bungee.BungeeSuperClassBindingModule;
import com.djrapitops.plan.modules.*;
import com.djrapitops.plan.modules.bungee.BungeePlanModule;
import com.djrapitops.plan.modules.bungee.BungeeServerPropertiesModule;
import com.djrapitops.plan.modules.bungee.BungeeSuperClassBindingModule;
import com.djrapitops.plan.system.PlanSystem;
import com.djrapitops.pluginbridge.plan.PluginBridgeModule;
import dagger.BindsInstance;
@ -41,7 +37,7 @@ import javax.inject.Singleton;
@Component(modules = {
BungeePlanModule.class,
SuperClassBindingModule.class,
SystemObjectBindingModule.class,
SystemObjectProvidingModule.class,
APFModule.class,
FilesModule.class,
ProxySuperClassBindingModule.class,

View File

@ -14,17 +14,16 @@
* 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.plugin;
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.plugin.command.CommandNode;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import javax.inject.Named;
import javax.inject.Singleton;
/**
* Dagger module for binding PlanBungee instance.
@ -32,18 +31,12 @@ import javax.inject.Singleton;
* @author Rsl1122
*/
@Module
public class BungeePlanModule {
public interface BungeePlanModule {
@Provides
@Singleton
PlanPlugin providePlanPlugin(PlanBungee plugin) {
return plugin;
}
@Binds
PlanPlugin bindPlanPlugin(PlanBungee plugin);
@Provides
@Singleton
@Binds
@Named("mainCommand")
CommandNode provideMainCommand(PlanBungeeCommand command) {
return command;
}
CommandNode bindMainCommand(PlanBungeeCommand command);
}

View File

@ -14,7 +14,7 @@
* 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.proxy.bungee;
package com.djrapitops.plan.modules.bungee;
import com.djrapitops.plan.PlanBungee;
import com.djrapitops.plan.system.info.server.properties.BungeeServerProperties;

View File

@ -14,7 +14,7 @@
* 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.proxy.bungee;
package com.djrapitops.plan.modules.bungee;
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
import com.djrapitops.plan.system.info.server.ServerInfo;
@ -22,10 +22,8 @@ import com.djrapitops.plan.system.listeners.BungeeListenerSystem;
import com.djrapitops.plan.system.listeners.ListenerSystem;
import com.djrapitops.plan.system.tasks.BungeeTaskSystem;
import com.djrapitops.plan.system.tasks.TaskSystem;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import javax.inject.Singleton;
/**
* Module for binding Bungee specific classes to the interface implementations.
@ -33,23 +31,14 @@ import javax.inject.Singleton;
* @author Rsl1122
*/
@Module
public class BungeeSuperClassBindingModule {
public interface BungeeSuperClassBindingModule {
@Provides
@Singleton
ServerInfo provideBungeeServerInfo(BungeeServerInfo bungeeServerInfo) {
return bungeeServerInfo;
}
@Binds
ServerInfo bindBungeeServerInfo(BungeeServerInfo bungeeServerInfo);
@Provides
@Singleton
TaskSystem provideBungeeTaskSystem(BungeeTaskSystem bungeeTaskSystem) {
return bungeeTaskSystem;
}
@Binds
TaskSystem bindBungeeTaskSystem(BungeeTaskSystem bungeeTaskSystem);
@Provides
@Singleton
ListenerSystem provideBungeeListenerSystem(BungeeListenerSystem bungeeListenerSystem) {
return bungeeListenerSystem;
}
@Binds
ListenerSystem bindBungeeListenerSystem(BungeeListenerSystem bungeeListenerSystem);
}

View File

@ -19,9 +19,9 @@ package com.djrapitops.plan.system.tasks;
import com.djrapitops.plan.PlanBungee;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer;
import com.djrapitops.plan.system.tasks.bungee.PingCountTimerBungee;
import com.djrapitops.plan.system.tasks.proxy.NetworkPageRefreshTask;
import com.djrapitops.plan.system.tasks.proxy.bungee.BungeeTPSCountTimer;
import com.djrapitops.plan.system.tasks.proxy.bungee.PingCountTimerBungee;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;

View File

@ -14,7 +14,7 @@
* 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.system.tasks.proxy.bungee;
package com.djrapitops.plan.system.tasks.bungee;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.data.container.builders.TPSBuilder;

View File

@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.djrapitops.plan.system.tasks.proxy.bungee;
package com.djrapitops.plan.system.tasks.bungee;
import com.djrapitops.plan.data.store.objects.DateObj;
import com.djrapitops.plan.system.processing.Processing;

View File

@ -0,0 +1 @@
mock-maker-inline

181
Plan/common/pom.xml Normal file
View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>Plan</artifactId>
<groupId>com.djrapitops</groupId>
<version>4.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Plan-common</artifactId>
<description>
Module that includes common functionality between all platforms.
- Contains functionality related dependencies.
- Contains abstractions and interfaces
</description>
<dependencies>
<!-- Framework for easier plugin development -->
<dependency>
<groupId>com.djrapitops</groupId>
<artifactId>AbstractPluginFramework-api</artifactId>
</dependency>
<dependency> <!-- SoftDepended Plugins -->
<groupId>com.djrapitops</groupId>
<artifactId>PlanPluginBridge</artifactId>
</dependency>
<dependency> <!-- HttpClient -->
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency> <!-- String Replacer -->
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>
<dependency> <!-- HTML Compression -->
<groupId>com.googlecode.htmlcompressor</groupId>
<artifactId>htmlcompressor</artifactId>
</dependency>
<dependency> <!-- Cache with invalidation -->
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
<dependency> <!-- H2 -->
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency> <!-- MySQL Connection Pool -->
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency> <!-- Geo IP -->
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
</dependency>
<dependency> <!-- Guava -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>clean package install</defaultGoal>
<finalName>${project.name}</finalName>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<resources>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*.keystore</include>
<include>**/*.css</include>
<include>**/*.yml</include>
<include>**/*.html</include>
<include>**/*.js</include>
<include>**/*.css</include>
<include>locale/*.txt</include>
<include>**/*.ico</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>com.djrapitops:*</include>
<include>org.apache.httpcomponents:*</include>
<include>commons-logging:*</include>
<include>commons-codec:*</include>
<include>org.apache.commons:commons-text</include>
<include>org.apache.commons:commons-lang3</include>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
<include>com.maxmind.geoip2:*</include>
<include>com.maxmind.db:*</include>
<include>com.fasterxml.jackson.core:*</include>
<include>com.google.dagger:*</include>
<include>javax.inject:*</include>
<include>com.github.ben-manes.caffeine:caffeine</include>
<include>com.googlecode.htmlcompressor:htmlcompressor</include>
<include>com.h2database:h2</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.apache</pattern>
<shadedPattern>plan.org.apache</shadedPattern>
<excludes>
<exclude>org.apache.logging.**</exclude>
</excludes>
</relocation>
<relocation>
<pattern>com.maxmind</pattern>
<shadedPattern>plan.com.maxmind</shadedPattern>
</relocation>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>plan.com.fasterxml</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer</pattern>
<shadedPattern>plan.com.zaxxer</shadedPattern>
</relocation>
<relocation>
<pattern>org.h2</pattern>
<shadedPattern>plan.org.h2</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.djrapitops.plan.utilities.metrics</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>plan.org.slf4j</shadedPattern>
</relocation>
</relocations>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<excludePackageNames>test.*</excludePackageNames>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -26,7 +26,6 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.utilities.PassEncryptUtil;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils;
@ -81,9 +80,6 @@ public class RegisterCommand extends CommandNode {
setArguments("<password>", "[name]", "[lvl]");
setShortHelp(locale.getString(CmdHelpLang.WEB_REGISTER));
setInDepthHelp(locale.getArray(DeepHelpLang.WEB_REGISTER));
if (Check.isBukkitAvailable()) {
setupFilter();
}
notEnoughArgsMsg = locale.getString(CommandLang.FAIL_REQ_ARGS, 3, Arrays.toString(getArguments()));
}
@ -163,11 +159,4 @@ public class RegisterCommand extends CommandNode {
}
});
}
/**
* Setups the command console output filter
*/
private void setupFilter() {
new RegisterCommandFilter().registerFilter();
}
}

View File

@ -16,12 +16,12 @@
*/
package com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plan.system.listeners.bukkit.PlayerOnlineListener;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.status.Status;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.Sender;
@ -39,12 +39,17 @@ import java.util.Arrays;
public class ManageDisableCommand extends CommandNode {
private final Locale locale;
private final Status status;
@Inject
public ManageDisableCommand(Locale locale) {
public ManageDisableCommand(
Locale locale,
Status status
) {
super("disable", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
this.locale = locale;
this.status = status;
setArguments("<feature>");
setShortHelp(locale.getString(CmdHelpLang.MANAGE_DISABLE));
@ -58,7 +63,7 @@ public class ManageDisableCommand extends CommandNode {
switch (args[0].toLowerCase()) {
case "kickcount":
PlayerOnlineListener.setCountKicks(false);
status.setCountKicks(false);
sender.sendMessage(locale.getString(CommandLang.FEATURE_DISABLED, "Kick Counting"));
break;
default:

Some files were not shown because too many files have changed in this diff Show More