mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2024-11-22 11:56:17 +01:00
Moved Massive Factions to its own module
This commit is contained in:
parent
c3fa896ed2
commit
1ebfaad641
14
Hook_MassiveFactions/build.gradle
Normal file
14
Hook_MassiveFactions/build.gradle
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
group 'Hook_MassiveFactions'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly "com.massivecraft:Factions:latest"
|
||||||
|
compileOnly "com.massivecraft:MassiveCore:latest"
|
||||||
|
compileOnly "org.spigotmc:v1_8_R3-Taco:latest"
|
||||||
|
compileOnly project(":API")
|
||||||
|
compileOnly parent
|
||||||
|
}
|
||||||
|
|
||||||
|
if (project.hasProperty('hook.compile_massivefactions') &&
|
||||||
|
!Boolean.valueOf(project.findProperty("hook.compile_massivefactions").toString())) {
|
||||||
|
project.tasks.all { task -> task.enabled = false }
|
||||||
|
}
|
48
build.gradle
48
build.gradle
@ -7,22 +7,32 @@ plugins {
|
|||||||
group 'WildLoaders'
|
group 'WildLoaders'
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
|
||||||
subprojects {
|
allprojects {
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'com.github.johnrengelman.shadow'
|
apply plugin: 'com.github.johnrengelman.shadow'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://repo.bg-software.com/repository/nms/' }
|
maven { url 'https://repo.bg-software.com/repository/nms/' }
|
||||||
|
maven { url 'https://repo.bg-software.com/repository/api/' }
|
||||||
maven { url 'https://repo.bg-software.com/repository/common/' }
|
maven { url 'https://repo.bg-software.com/repository/common/' }
|
||||||
|
maven { url 'https://repo.bg-software.com/repository/public-libs/' }
|
||||||
|
|
||||||
|
String mavenUsername = System.getenv('mavenUsername') == null ? project.mavenUsername : System.getenv('mavenUsername');
|
||||||
|
String mavenPassword = System.getenv('mavenPassword') == null ? project.mavenUsername : System.getenv('mavenPassword');
|
||||||
|
|
||||||
|
if (mavenUsername != null && mavenPassword != null) {
|
||||||
|
maven {
|
||||||
|
url 'https://repo.bg-software.com/repository/private-libs/'
|
||||||
|
credentials {
|
||||||
|
username mavenUsername
|
||||||
|
password mavenPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'com.bgsoftware.common.reflection:ReflectionUtils:latest'
|
compileOnly "com.bgsoftware.common.reflection:ReflectionUtils:latest"
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
archiveName = "${project.name}.jar"
|
|
||||||
destinationDir = file("../archive/")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build {
|
build {
|
||||||
@ -30,25 +40,11 @@ subprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
subprojects {
|
||||||
maven { url 'https://repo.bg-software.com/repository/nms/' }
|
shadowJar {
|
||||||
maven { url 'https://repo.bg-software.com/repository/api/' }
|
archiveFileName = "${project.name}.jar"
|
||||||
maven { url 'https://repo.bg-software.com/repository/public-libs/' }
|
destinationDirectory = file("../archive/")
|
||||||
maven { url 'https://repo.bg-software.com/repository/common/' }
|
|
||||||
|
|
||||||
String mavenUsername = project.hasProperty('mavenUsername') ? project.mavenUsername : System.getenv('mavenUsername');
|
|
||||||
String mavenPassword = project.hasProperty('mavenPassword') ? project.mavenPassword : System.getenv('mavenPassword');
|
|
||||||
|
|
||||||
if(mavenUsername != null && mavenPassword != null) {
|
|
||||||
maven {
|
|
||||||
url 'https://repo.bg-software.com/repository/private-libs/'
|
|
||||||
credentials {
|
|
||||||
username mavenUsername
|
|
||||||
password mavenPassword
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -62,10 +58,8 @@ dependencies {
|
|||||||
compileOnly 'org.spigotmc:v1_16_R3-Tuinity:latest'
|
compileOnly 'org.spigotmc:v1_16_R3-Tuinity:latest'
|
||||||
|
|
||||||
// Plugin Hooks
|
// Plugin Hooks
|
||||||
compileOnly "com.massivecraft:Factions:latest"
|
|
||||||
compileOnly "com.drtshock:FactionsUUID:latest"
|
compileOnly "com.drtshock:FactionsUUID:latest"
|
||||||
compileOnly "net.prosavage:FactionsX:latest"
|
compileOnly "net.prosavage:FactionsX:latest"
|
||||||
compileOnly "com.massivecraft:MassiveCore:latest"
|
|
||||||
compileOnly "com.bgsoftware:SuperiorSkyblockAPI:latest"
|
compileOnly "com.bgsoftware:SuperiorSkyblockAPI:latest"
|
||||||
compileOnly "com.songoda:EpicSpawners-6:latest"
|
compileOnly "com.songoda:EpicSpawners-6:latest"
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,5 @@ include 'v1_15_R1'
|
|||||||
include 'v1_16_R3'
|
include 'v1_16_R3'
|
||||||
include 'v1_17_R1'
|
include 'v1_17_R1'
|
||||||
include 'v1_18_R1'
|
include 'v1_18_R1'
|
||||||
|
include 'Hook_MassiveFactions'
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public final class WildLoadersPlugin extends JavaPlugin implements WildLoaders {
|
|||||||
dataHandler = new DataHandler(this);
|
dataHandler = new DataHandler(this);
|
||||||
loadersHandler = new LoadersHandler(this);
|
loadersHandler = new LoadersHandler(this);
|
||||||
npcHandler = new NPCHandler(this);
|
npcHandler = new NPCHandler(this);
|
||||||
providersHandler = new ProvidersHandler();
|
providersHandler = new ProvidersHandler(this);
|
||||||
settingsHandler = new SettingsHandler(this);
|
settingsHandler = new SettingsHandler(this);
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(new BlocksListener(this), this);
|
getServer().getPluginManager().registerEvents(new BlocksListener(this), this);
|
||||||
|
@ -1,49 +1,65 @@
|
|||||||
package com.bgsoftware.wildloaders.handlers;
|
package com.bgsoftware.wildloaders.handlers;
|
||||||
|
|
||||||
|
import com.bgsoftware.wildloaders.WildLoadersPlugin;
|
||||||
import com.bgsoftware.wildloaders.api.hooks.ClaimsProvider;
|
import com.bgsoftware.wildloaders.api.hooks.ClaimsProvider;
|
||||||
import com.bgsoftware.wildloaders.api.hooks.TickableProvider;
|
import com.bgsoftware.wildloaders.api.hooks.TickableProvider;
|
||||||
import com.bgsoftware.wildloaders.api.managers.ProvidersManager;
|
import com.bgsoftware.wildloaders.api.managers.ProvidersManager;
|
||||||
import com.bgsoftware.wildloaders.hooks.ClaimsProvider_FactionsUUID;
|
import com.bgsoftware.wildloaders.hooks.ClaimsProvider_FactionsUUID;
|
||||||
import com.bgsoftware.wildloaders.hooks.ClaimsProvider_FactionsX;
|
import com.bgsoftware.wildloaders.hooks.ClaimsProvider_FactionsX;
|
||||||
import com.bgsoftware.wildloaders.hooks.ClaimsProvider_MassiveFactions;
|
|
||||||
import com.bgsoftware.wildloaders.hooks.ClaimsProvider_SuperiorSkyblock;
|
import com.bgsoftware.wildloaders.hooks.ClaimsProvider_SuperiorSkyblock;
|
||||||
import com.bgsoftware.wildloaders.hooks.TickableProvider_EpicSpawners;
|
import com.bgsoftware.wildloaders.hooks.TickableProvider_EpicSpawners;
|
||||||
import com.bgsoftware.wildloaders.utils.threads.Executor;
|
import com.bgsoftware.wildloaders.utils.threads.Executor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public final class ProvidersHandler implements ProvidersManager {
|
public final class ProvidersHandler implements ProvidersManager {
|
||||||
|
|
||||||
|
private final WildLoadersPlugin plugin;
|
||||||
|
|
||||||
private final List<ClaimsProvider> claimsProviders = new ArrayList<>();
|
private final List<ClaimsProvider> claimsProviders = new ArrayList<>();
|
||||||
private final List<TickableProvider> tickableProviders = new ArrayList<>();
|
private final List<TickableProvider> tickableProviders = new ArrayList<>();
|
||||||
|
|
||||||
public ProvidersHandler(){
|
public ProvidersHandler(WildLoadersPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
Executor.sync(() -> {
|
Executor.sync(() -> {
|
||||||
// Loading the claim providers
|
loadClaimsProviders();
|
||||||
if(Bukkit.getPluginManager().isPluginEnabled("Factions")){
|
loadTickableProviders();
|
||||||
if(Bukkit.getPluginManager().getPlugin("Factions").getDescription().getAuthors().contains("drtshock"))
|
|
||||||
addClaimsProvider(new ClaimsProvider_FactionsUUID());
|
|
||||||
else
|
|
||||||
addClaimsProvider(new ClaimsProvider_MassiveFactions());
|
|
||||||
}
|
|
||||||
if(Bukkit.getPluginManager().isPluginEnabled("FactionsX")){
|
|
||||||
addClaimsProvider(new ClaimsProvider_FactionsX());
|
|
||||||
}
|
|
||||||
if(Bukkit.getPluginManager().isPluginEnabled("SuperiorSkyblock2")){
|
|
||||||
addClaimsProvider(new ClaimsProvider_SuperiorSkyblock());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loading the tickable providers
|
|
||||||
if(Bukkit.getPluginManager().isPluginEnabled("EpicSpawners")){
|
|
||||||
addTickableProvider(new TickableProvider_EpicSpawners());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadClaimsProviders() {
|
||||||
|
// Loading the claim providers
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("Factions")) {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("Factions").getDescription().getAuthors().contains("drtshock")) {
|
||||||
|
addClaimsProvider(new ClaimsProvider_FactionsUUID());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Optional<ClaimsProvider> claimsProvider = createInstance("ClaimsProvider_MassiveFactions");
|
||||||
|
claimsProvider.ifPresent(this::addClaimsProvider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("FactionsX")) {
|
||||||
|
addClaimsProvider(new ClaimsProvider_FactionsX());
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("SuperiorSkyblock2")) {
|
||||||
|
addClaimsProvider(new ClaimsProvider_SuperiorSkyblock());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadTickableProviders() {
|
||||||
|
// Loading the tickable providers
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners")) {
|
||||||
|
addTickableProvider(new TickableProvider_EpicSpawners());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addClaimsProvider(ClaimsProvider claimsProvider) {
|
public void addClaimsProvider(ClaimsProvider claimsProvider) {
|
||||||
claimsProviders.add(claimsProvider);
|
claimsProviders.add(claimsProvider);
|
||||||
@ -54,8 +70,8 @@ public final class ProvidersHandler implements ProvidersManager {
|
|||||||
tickableProviders.add(tickableProvider);
|
tickableProviders.add(tickableProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChunkAccess(UUID player, Chunk chunk){
|
public boolean hasChunkAccess(UUID player, Chunk chunk) {
|
||||||
for(ClaimsProvider claimsProvider : claimsProviders) {
|
for (ClaimsProvider claimsProvider : claimsProviders) {
|
||||||
if (claimsProvider.hasClaimAccess(player, chunk))
|
if (claimsProvider.hasClaimAccess(player, chunk))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -63,8 +79,34 @@ public final class ProvidersHandler implements ProvidersManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tick(Chunk[] chunks){
|
public void tick(Chunk[] chunks) {
|
||||||
tickableProviders.forEach(tickableProvider -> tickableProvider.tick(chunks));
|
tickableProviders.forEach(tickableProvider -> tickableProvider.tick(chunks));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T> Optional<T> createInstance(String className) {
|
||||||
|
try {
|
||||||
|
Class<?> clazz = Class.forName("com.bgsoftware.superiorskyblock.hooks.provider." + className);
|
||||||
|
try {
|
||||||
|
Method compatibleMethod = clazz.getDeclaredMethod("isCompatible");
|
||||||
|
if (!(boolean) compatibleMethod.invoke(null))
|
||||||
|
return Optional.empty();
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Constructor<?> constructor = clazz.getConstructor(WildLoadersPlugin.class);
|
||||||
|
// noinspection unchecked
|
||||||
|
return Optional.of((T) constructor.newInstance(plugin));
|
||||||
|
} catch (Exception error) {
|
||||||
|
// noinspection unchecked
|
||||||
|
return Optional.of((T) clazz.newInstance());
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException ignored) {
|
||||||
|
return Optional.empty();
|
||||||
|
} catch (Exception error) {
|
||||||
|
error.printStackTrace();
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user