mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-28 02:54:20 +01:00
PluginBridge now split into Bukkit & Bungee for future compatibility.
This commit is contained in:
parent
0b57955c9c
commit
0d4c065b52
@ -6,7 +6,7 @@
|
|||||||
<version>4.2.0-SNAPSHOT</version>
|
<version>4.2.0-SNAPSHOT</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||||
<testSourceDirectory>${basedir}/test/main/java</testSourceDirectory>
|
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
|
||||||
<defaultGoal>clean package install</defaultGoal>
|
<defaultGoal>clean package install</defaultGoal>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
@ -254,60 +254,37 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.powermock</groupId>
|
|
||||||
<artifactId>powermock</artifactId>
|
|
||||||
<version>1.6.6</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.powermock</groupId>
|
|
||||||
<artifactId>powermock-api-mockito</artifactId>
|
|
||||||
<version>1.6.6</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.powermock</groupId>
|
|
||||||
<artifactId>powermock-module-junit4</artifactId>
|
|
||||||
<version>1.6.6</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.powermock</groupId>
|
|
||||||
<artifactId>powermock-module-junit4-rule</artifactId>
|
|
||||||
<version>1.6.6</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.powermock</groupId>
|
|
||||||
<artifactId>powermock-classloading-xstream</artifactId>
|
|
||||||
<version>1.6.6</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>1.10.19</version>
|
<version>2.13.0</version>
|
||||||
<scope>compile</scope>
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>byte-buddy</artifactId>
|
||||||
|
<groupId>net.bytebuddy</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>byte-buddy-agent</artifactId>
|
||||||
|
<groupId>net.bytebuddy</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>objenesis</artifactId>
|
||||||
|
<groupId>org.objenesis</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.powermock</groupId>
|
<groupId>org.xerial</groupId>
|
||||||
<artifactId>powermock-api-easymock</artifactId>
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
<version>1.6.6</version>
|
<version>3.21.0</version>
|
||||||
<scope>compile</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.easymock</groupId>
|
|
||||||
<artifactId>easymock</artifactId>
|
|
||||||
<version>3.4</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>4.12</version>
|
||||||
<scope>compile</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
|
@ -2,6 +2,7 @@ package com.djrapitops.pluginbridge.plan;
|
|||||||
|
|
||||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
|
import com.djrapitops.plugin.api.Check;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.pluginbridge.plan.aac.AdvancedAntiCheatHook;
|
import com.djrapitops.pluginbridge.plan.aac.AdvancedAntiCheatHook;
|
||||||
import com.djrapitops.pluginbridge.plan.advancedachievements.AdvancedAchievementsHook;
|
import com.djrapitops.pluginbridge.plan.advancedachievements.AdvancedAchievementsHook;
|
||||||
@ -51,7 +52,38 @@ public class Bridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void hook(HookHandler h) {
|
public static void hook(HookHandler h) {
|
||||||
Hook[] hooks = new Hook[]{
|
Hook[] hooks = getHooks(h);
|
||||||
|
hookInto(hooks);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void hookInto(Hook[] hooks) {
|
||||||
|
for (Hook hook : hooks) {
|
||||||
|
try {
|
||||||
|
hook.hook();
|
||||||
|
} catch (Exception | NoClassDefFoundError e) {
|
||||||
|
if (Settings.DEV_MODE.isTrue()) {
|
||||||
|
Log.toLog("PluginBridge", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Hook[] getHooks(HookHandler h) {
|
||||||
|
Hook[] hooks;
|
||||||
|
if (Check.isBukkitAvailable()) {
|
||||||
|
hooks = getBukkitHooks(h);
|
||||||
|
} else {
|
||||||
|
hooks = getBungeeHooks(h);
|
||||||
|
}
|
||||||
|
return hooks;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Hook[] getBungeeHooks(HookHandler h) {
|
||||||
|
return new Hook[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Hook[] getBukkitHooks(HookHandler h) {
|
||||||
|
return new Hook[]{
|
||||||
new AdvancedAntiCheatHook(h),
|
new AdvancedAntiCheatHook(h),
|
||||||
new AdvancedAchievementsHook(h),
|
new AdvancedAchievementsHook(h),
|
||||||
new ASkyBlockHook(h),
|
new ASkyBlockHook(h),
|
||||||
@ -70,14 +102,5 @@ public class Bridge {
|
|||||||
new VaultHook(h),
|
new VaultHook(h),
|
||||||
new ViaVersionHook(h)
|
new ViaVersionHook(h)
|
||||||
};
|
};
|
||||||
for (Hook hook : hooks) {
|
|
||||||
try {
|
|
||||||
hook.hook();
|
|
||||||
} catch (Exception | NoClassDefFoundError e) {
|
|
||||||
if (Settings.DEV_MODE.isTrue()) {
|
|
||||||
Log.toLog("PluginBridge", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ package com.djrapitops.pluginbridge.plan.aac;
|
|||||||
|
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.processing.processors.Processor;
|
import com.djrapitops.plan.system.processing.Processor;
|
||||||
import com.djrapitops.plan.utilities.MiscUtils;
|
import com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import me.konsolas.aac.api.AACAPIProvider;
|
import me.konsolas.aac.api.AACAPIProvider;
|
||||||
@ -42,15 +42,13 @@ public class PlayerHackKickListener implements Listener {
|
|||||||
int violations = AACAPIProvider.getAPI().getViolationLevel(player, hackType);
|
int violations = AACAPIProvider.getAPI().getViolationLevel(player, hackType);
|
||||||
|
|
||||||
HackObject hackObject = new HackObject(uuid, time, hackType, violations);
|
HackObject hackObject = new HackObject(uuid, time, hackType, violations);
|
||||||
new Processor<UUID>(uuid) {
|
|
||||||
@Override
|
Processor.queue(() -> {
|
||||||
public void process() {
|
|
||||||
try {
|
try {
|
||||||
new HackerTable((SQLDB) Database.getActive()).insertHackRow(hackObject);
|
new HackerTable((SQLDB) Database.getActive()).insertHackRow(hackObject);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}.queue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ package com.djrapitops.pluginbridge.plan.protocolsupport;
|
|||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.processing.processors.Processor;
|
import com.djrapitops.plan.system.processing.Processor;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable;
|
import com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -40,15 +40,12 @@ public class PlayerVersionListener implements Listener {
|
|||||||
ProtocolVersion protocolVersion = ProtocolSupportAPI.getProtocolVersion(player);
|
ProtocolVersion protocolVersion = ProtocolSupportAPI.getProtocolVersion(player);
|
||||||
int playerVersion = protocolVersion.getId();
|
int playerVersion = protocolVersion.getId();
|
||||||
Plan plan = Plan.getInstance();
|
Plan plan = Plan.getInstance();
|
||||||
new Processor<UUID>(uuid) {
|
Processor.queue(() -> {
|
||||||
@Override
|
|
||||||
public void process() {
|
|
||||||
try {
|
try {
|
||||||
new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion);
|
new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}.queue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ package com.djrapitops.pluginbridge.plan.viaversion;
|
|||||||
|
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.processing.processors.Processor;
|
import com.djrapitops.plan.system.processing.Processor;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -36,16 +36,12 @@ public class PlayerVersionListener implements Listener {
|
|||||||
public void onJoin(PlayerJoinEvent event) {
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
UUID uuid = event.getPlayer().getUniqueId();
|
UUID uuid = event.getPlayer().getUniqueId();
|
||||||
int playerVersion = viaAPI.getPlayerVersion(uuid);
|
int playerVersion = viaAPI.getPlayerVersion(uuid);
|
||||||
new Processor<UUID>(uuid) {
|
Processor.queue(() -> {
|
||||||
@Override
|
|
||||||
public void process() {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion);
|
new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.toLog(this.getClass().getName() + ":PlanViaVersionJoinListener", e);
|
Log.toLog(this.getClass().getName() + ":PlanViaVersionJoinListener", e);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}.queue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user