PluginBridge now split into Bukkit & Bungee for future compatibility.

This commit is contained in:
Rsl1122 2018-01-27 17:37:42 +02:00
parent 0b57955c9c
commit 0d4c065b52
5 changed files with 77 additions and 86 deletions

View File

@ -6,7 +6,7 @@
<version>4.2.0-SNAPSHOT</version>
<build>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<testSourceDirectory>${basedir}/test/main/java</testSourceDirectory>
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<defaultGoal>clean package install</defaultGoal>
<resources>
<resource>
@ -254,60 +254,37 @@
</exclusion>
</exclusions>
</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>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>compile</scope>
<version>2.13.0</version>
<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>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>1.6.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.4</version>
<scope>compile</scope>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.21.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>

View File

@ -2,6 +2,7 @@ package com.djrapitops.pluginbridge.plan;
import com.djrapitops.plan.data.plugin.HookHandler;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.pluginbridge.plan.aac.AdvancedAntiCheatHook;
import com.djrapitops.pluginbridge.plan.advancedachievements.AdvancedAchievementsHook;
@ -51,7 +52,38 @@ public class Bridge {
}
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 AdvancedAchievementsHook(h),
new ASkyBlockHook(h),
@ -70,14 +102,5 @@ public class Bridge {
new VaultHook(h),
new ViaVersionHook(h)
};
for (Hook hook : hooks) {
try {
hook.hook();
} catch (Exception | NoClassDefFoundError e) {
if (Settings.DEV_MODE.isTrue()) {
Log.toLog("PluginBridge", e);
}
}
}
}
}

View File

@ -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.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.plugin.api.utility.log.Log;
import me.konsolas.aac.api.AACAPIProvider;
@ -42,15 +42,13 @@ public class PlayerHackKickListener implements Listener {
int violations = AACAPIProvider.getAPI().getViolationLevel(player, hackType);
HackObject hackObject = new HackObject(uuid, time, hackType, violations);
new Processor<UUID>(uuid) {
@Override
public void process() {
try {
new HackerTable((SQLDB) Database.getActive()).insertHackRow(hackObject);
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);
}
Processor.queue(() -> {
try {
new HackerTable((SQLDB) Database.getActive()).insertHackRow(hackObject);
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);
}
}.queue();
});
}
}

View File

@ -8,7 +8,7 @@ package com.djrapitops.pluginbridge.plan.protocolsupport;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.system.database.databases.Database;
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.pluginbridge.plan.viaversion.ProtocolTable;
import org.bukkit.entity.Player;
@ -40,15 +40,12 @@ public class PlayerVersionListener implements Listener {
ProtocolVersion protocolVersion = ProtocolSupportAPI.getProtocolVersion(player);
int playerVersion = protocolVersion.getId();
Plan plan = Plan.getInstance();
new Processor<UUID>(uuid) {
@Override
public void process() {
try {
new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion);
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);
}
Processor.queue(() -> {
try {
new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion);
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);
}
}.queue();
});
}
}

View File

@ -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.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 org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -36,16 +36,12 @@ public class PlayerVersionListener implements Listener {
public void onJoin(PlayerJoinEvent event) {
UUID uuid = event.getPlayer().getUniqueId();
int playerVersion = viaAPI.getPlayerVersion(uuid);
new Processor<UUID>(uuid) {
@Override
public void process() {
try {
new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion);
} catch (SQLException e) {
Log.toLog(this.getClass().getName() + ":PlanViaVersionJoinListener", e);
}
Processor.queue(() -> {
try {
new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion);
} catch (SQLException e) {
Log.toLog(this.getClass().getName() + ":PlanViaVersionJoinListener", e);
}
}.queue();
});
}
}