Skip to content

Commit

Permalink
Fixed integration issue with newer versions of Slimefun (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Jan 25, 2022
1 parent c0271ef commit 7437156
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Hook_Slimefun/build.gradle
Expand Up @@ -3,7 +3,7 @@ group 'Hook_Slimefun'
dependencies {
compileOnly 'me.mrcookieslime:Slimefun4:latest'
compileOnly 'me.mrcookieslime:Slimefun4-Dev:latest'
compileOnly 'me.mrcookieslime:Slimefun4-Relocations:latest'
compileOnly 'me.mrcookieslime:Slimefun4-Relocations:b999'
compileOnly "org.spigotmc:v1_8_R3-Taco:latest"
compileOnly project(":API")
compileOnly parent
Expand Down
@@ -1,32 +1,36 @@
package com.bgsoftware.superiorskyblock.hooks.support;

import com.bgsoftware.common.reflection.ReflectField;
import com.bgsoftware.common.reflection.ReflectMethod;
import com.bgsoftware.superiorskyblock.SuperiorSkyblockPlugin;
import com.bgsoftware.superiorskyblock.api.events.IslandChunkResetEvent;
import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.island.IslandPrivilege;
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import com.bgsoftware.superiorskyblock.island.flags.IslandFlags;
import com.bgsoftware.superiorskyblock.island.permissions.IslandPrivileges;
import com.bgsoftware.superiorskyblock.threads.Executor;
import com.bgsoftware.superiorskyblock.utils.debug.PluginDebugger;
import com.bgsoftware.superiorskyblock.utils.logic.BlocksLogic;
import com.bgsoftware.superiorskyblock.utils.logic.StackedBlocksLogic;
import com.bgsoftware.superiorskyblock.threads.Executor;
import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent;
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.ProtectionModule;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.cscorelib2.config.Config;
import me.mrCookieSlime.Slimefun.cscorelib2.protection.ProtectionManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;

import java.util.Map;
import java.util.function.Function;

@SuppressWarnings("unused")
public final class SlimefunHook {
Expand Down Expand Up @@ -151,6 +155,10 @@ public void register() {
private static final class Slimefun4RelocationsProtectionModule implements
io.github.thebusybiscuit.slimefun4.libraries.dough.protection.ProtectionModule {

private static final ReflectMethod<Void> OLD_REGISTER_MODULE = new ReflectMethod<>(
io.github.thebusybiscuit.slimefun4.libraries.dough.protection.ProtectionManager.class,
"registerModule", Server.class, String.class, Function.class);

@Override
public void load() {
// Do nothing.
Expand All @@ -169,7 +177,13 @@ public boolean hasPermission(OfflinePlayer offlinePlayer, Location location,

public void register() {
Executor.sync(() -> {
Slimefun.getProtectionManager().registerModule(Bukkit.getServer(), plugin.getName(), pl -> this);
if (OLD_REGISTER_MODULE.isValid()) {
OLD_REGISTER_MODULE.invoke(Slimefun.getProtectionManager(), Bukkit.getServer(), plugin.getName(),
(Function<Plugin, ProtectionModule>) pl -> this);
} else {
Slimefun.getProtectionManager().registerModule(Bukkit.getServer().getPluginManager(),
plugin.getName(), pl -> this);
}
}, 2L);
}

Expand Down

0 comments on commit 7437156

Please sign in to comment.