3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

Add support for delegating permissions to Sponge.

When Sponge is not installed, behaviour is as before.
Closes #331
Dieser Commit ist enthalten in:
zml 2015-06-29 12:57:01 -07:00 committet von Kenzie Togami
Ursprung 0d5c115e4d
Commit aa3a2d4764
4 geänderte Dateien mit 29 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -55,6 +55,7 @@
<allow pkg="org.apache.logging.log4j"/>
<allow pkg="org.lwjgl"/>
<allow pkg="io.netty.buffer"/>
<allow pkg="org.spongepowered.api" />
</subpackage>
</subpackage>
</import-control>

Datei anzeigen

@ -15,9 +15,14 @@ apply plugin: 'forge'
dependencies {
compile project(':worldedit-core')
compile 'org.spongepowered:spongeapi:2.1-SNAPSHOT'
testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1'
}
repositories {
maven { url ="https://repo.spongepowered.org/maven" }
}
minecraft {
ext.forgeVersion = "11.14.0.1281"
version = "1.8-$forgeVersion-1.8"

Datei anzeigen

@ -23,6 +23,7 @@ import net.minecraft.command.ICommand;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.WorldSettings.GameType;
import net.minecraftforge.fml.common.FMLCommonHandler;
import org.spongepowered.api.entity.player.Player;
public interface ForgePermissionsProvider {
@ -49,4 +50,17 @@ public interface ForgePermissionsProvider {
@Override
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) {
}
}
}

Datei anzeigen

@ -36,6 +36,7 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
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.
*/
@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 static Logger logger;
@ -116,8 +117,13 @@ public class ForgeWorldEdit {
this.platform = new ForgePlatform(this);
WorldEdit.getInstance().getPlatformManager().register(platform);
if (Loader.isModLoaded("Sponge")) {
this.provider = new ForgePermissionsProvider.SpongePermissionsProvider();
} else {
this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform);
}
}
@EventHandler
public void serverStopping(FMLServerStoppingEvent event) {