mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Add support for delegating permissions to Sponge.
When Sponge is not installed, behaviour is as before. Closes #331
This commit is contained in:
parent
0d5c115e4d
commit
aa3a2d4764
@ -55,6 +55,7 @@
|
|||||||
<allow pkg="org.apache.logging.log4j"/>
|
<allow pkg="org.apache.logging.log4j"/>
|
||||||
<allow pkg="org.lwjgl"/>
|
<allow pkg="org.lwjgl"/>
|
||||||
<allow pkg="io.netty.buffer"/>
|
<allow pkg="io.netty.buffer"/>
|
||||||
|
<allow pkg="org.spongepowered.api" />
|
||||||
</subpackage>
|
</subpackage>
|
||||||
</subpackage>
|
</subpackage>
|
||||||
</import-control>
|
</import-control>
|
||||||
|
@ -15,9 +15,14 @@ apply plugin: 'forge'
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':worldedit-core')
|
compile project(':worldedit-core')
|
||||||
|
compile 'org.spongepowered:spongeapi:2.1-SNAPSHOT'
|
||||||
testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1'
|
testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven { url ="https://repo.spongepowered.org/maven" }
|
||||||
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
ext.forgeVersion = "11.14.0.1281"
|
ext.forgeVersion = "11.14.0.1281"
|
||||||
version = "1.8-$forgeVersion-1.8"
|
version = "1.8-$forgeVersion-1.8"
|
||||||
@ -31,7 +36,7 @@ project.archivesBaseName = "${project.archivesBaseName}-mc${minecraft.version}"
|
|||||||
processResources {
|
processResources {
|
||||||
from (sourceSets.main.resources.srcDirs) {
|
from (sourceSets.main.resources.srcDirs) {
|
||||||
expand 'version': project.version,
|
expand 'version': project.version,
|
||||||
'mcVersion': project.minecraft.version,
|
'mcVersion': project.minecraft.version,
|
||||||
'forgeVersion': project.minecraft.forgeVersion,
|
'forgeVersion': project.minecraft.forgeVersion,
|
||||||
'internalVersion': project.internalVersion
|
'internalVersion': project.internalVersion
|
||||||
include 'mcmod.info'
|
include 'mcmod.info'
|
||||||
|
@ -23,6 +23,7 @@ import net.minecraft.command.ICommand;
|
|||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.world.WorldSettings.GameType;
|
import net.minecraft.world.WorldSettings.GameType;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
|
import org.spongepowered.api.entity.player.Player;
|
||||||
|
|
||||||
public interface ForgePermissionsProvider {
|
public interface ForgePermissionsProvider {
|
||||||
|
|
||||||
@ -49,4 +50,17 @@ public interface ForgePermissionsProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void registerPermission(ICommand command, String permission) {}
|
public void registerPermission(ICommand command, String permission) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class SpongePermissionsProvider implements ForgePermissionsProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(EntityPlayerMP player, String permission) {
|
||||||
|
return ((Player) player).hasPermission(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerPermission(ICommand command, String permission) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import net.minecraftforge.common.MinecraftForge;
|
|||||||
import net.minecraftforge.event.CommandEvent;
|
import net.minecraftforge.event.CommandEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
|
import net.minecraftforge.fml.common.Loader;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||||
import net.minecraftforge.fml.common.Mod.Instance;
|
import net.minecraftforge.fml.common.Mod.Instance;
|
||||||
@ -60,7 +61,7 @@ import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
|||||||
/**
|
/**
|
||||||
* The Forge implementation of WorldEdit.
|
* The Forge implementation of WorldEdit.
|
||||||
*/
|
*/
|
||||||
@Mod(modid = ForgeWorldEdit.MOD_ID, name = "WorldEdit", version = "%VERSION%", acceptableRemoteVersions = "*")
|
@Mod(modid = ForgeWorldEdit.MOD_ID, name = "WorldEdit", version = "%VERSION%", acceptableRemoteVersions = "*", dependencies = "after:Sponge")
|
||||||
public class ForgeWorldEdit {
|
public class ForgeWorldEdit {
|
||||||
|
|
||||||
public static Logger logger;
|
public static Logger logger;
|
||||||
@ -116,7 +117,12 @@ public class ForgeWorldEdit {
|
|||||||
this.platform = new ForgePlatform(this);
|
this.platform = new ForgePlatform(this);
|
||||||
|
|
||||||
WorldEdit.getInstance().getPlatformManager().register(platform);
|
WorldEdit.getInstance().getPlatformManager().register(platform);
|
||||||
this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform);
|
|
||||||
|
if (Loader.isModLoaded("Sponge")) {
|
||||||
|
this.provider = new ForgePermissionsProvider.SpongePermissionsProvider();
|
||||||
|
} else {
|
||||||
|
this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user