diff --git a/src/main/java/com/sekwah/advancedportals/core/api/effect/TestEffect.java b/src/main/java/com/sekwah/advancedportals/core/api/effect/TestEffect.java index a280e681..c09f2d6d 100644 --- a/src/main/java/com/sekwah/advancedportals/core/api/effect/TestEffect.java +++ b/src/main/java/com/sekwah/advancedportals/core/api/effect/TestEffect.java @@ -9,7 +9,7 @@ import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; */ public class TestEffect extends WarpEffect { @Override - void onWarp(PlayerContainer player, PortalLocation loc, Action action, Type type, AdvancedPortal portal) { + protected void onWarp(PlayerContainer player, PortalLocation loc, Action action, Type type, AdvancedPortal portal) { } } diff --git a/src/main/java/com/sekwah/advancedportals/core/api/effect/WarpEffect.java b/src/main/java/com/sekwah/advancedportals/core/api/effect/WarpEffect.java index d8aa3627..88f6f945 100644 --- a/src/main/java/com/sekwah/advancedportals/core/api/effect/WarpEffect.java +++ b/src/main/java/com/sekwah/advancedportals/core/api/effect/WarpEffect.java @@ -15,7 +15,7 @@ import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; */ public abstract class WarpEffect { - abstract void onWarp(PlayerContainer player, PortalLocation loc, Action action, Type type, AdvancedPortal portal); + protected abstract void onWarp(PlayerContainer player, PortalLocation loc, Action action, Type type, AdvancedPortal portal); public enum Action { ENTER, diff --git a/src/main/java/com/sekwah/advancedportals/coreconnector/container/ServerContainer.java b/src/main/java/com/sekwah/advancedportals/coreconnector/container/ServerContainer.java new file mode 100644 index 00000000..85192c7d --- /dev/null +++ b/src/main/java/com/sekwah/advancedportals/coreconnector/container/ServerContainer.java @@ -0,0 +1,7 @@ +package com.sekwah.advancedportals.coreconnector.container; + +public interface ServerContainer { + + WorldContainer getWorld(String name); + +} diff --git a/src/main/java/com/sekwah/advancedportals/forge/coreconnector/command/ForgeCommandHandler.java b/src/main/java/com/sekwah/advancedportals/forge/coreconnector/command/ForgeCommandHandler.java index 64ba6eb1..56a165d4 100644 --- a/src/main/java/com/sekwah/advancedportals/forge/coreconnector/command/ForgeCommandHandler.java +++ b/src/main/java/com/sekwah/advancedportals/forge/coreconnector/command/ForgeCommandHandler.java @@ -23,6 +23,16 @@ public class ForgeCommandHandler extends CommandBase this.commandExecutor = commandExecutor; } + @Override + public int getRequiredPermissionLevel() { + return 0; + } + + @Override + public boolean checkPermission(MinecraftServer p_checkPermission_1_, ICommandSender p_checkPermission_2_) { + return true; + } + @Override public String getName() { return commandName; diff --git a/src/main/java/com/sekwah/advancedportals/forge/coreconnector/container/ForgeCommandSenderContainer.java b/src/main/java/com/sekwah/advancedportals/forge/coreconnector/container/ForgeCommandSenderContainer.java index d83bcf01..52b91bc2 100644 --- a/src/main/java/com/sekwah/advancedportals/forge/coreconnector/container/ForgeCommandSenderContainer.java +++ b/src/main/java/com/sekwah/advancedportals/forge/coreconnector/container/ForgeCommandSenderContainer.java @@ -4,7 +4,9 @@ import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.server.management.UserListOpsEntry; import net.minecraft.util.text.TextComponentString; +import net.minecraftforge.fml.common.FMLCommonHandler; public class ForgeCommandSenderContainer implements CommandSenderContainer { private final ICommandSender sender; @@ -20,7 +22,26 @@ public class ForgeCommandSenderContainer implements CommandSenderContainer { @Override public boolean isOp() { - return false; + if(this.sender.getCommandSenderEntity() instanceof EntityPlayer) { + + if(!FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().canSendCommands(((EntityPlayer) this.sender).getGameProfile())) { + return false; + } + else { + UserListOpsEntry userlistopsentry = FMLCommonHandler.instance().getMinecraftServerInstance() + .getPlayerList().getOppedPlayers().getEntry(((EntityPlayer) this.sender).getGameProfile()); + if (userlistopsentry != null) { + return userlistopsentry.getPermissionLevel() >= 2; + } else { + return FMLCommonHandler.instance().getMinecraftServerInstance().getOpPermissionLevel() + >= 2; + } + } + + } + else { + return false; + } } @Override diff --git a/src/main/java/com/sekwah/advancedportals/forge/coreconnector/container/ForgePlayerContainer.java b/src/main/java/com/sekwah/advancedportals/forge/coreconnector/container/ForgePlayerContainer.java index 822477d7..de360267 100644 --- a/src/main/java/com/sekwah/advancedportals/forge/coreconnector/container/ForgePlayerContainer.java +++ b/src/main/java/com/sekwah/advancedportals/forge/coreconnector/container/ForgePlayerContainer.java @@ -5,13 +5,18 @@ import com.sekwah.advancedportals.core.entities.PortalLocation; import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; import com.sekwah.advancedportals.coreconnector.container.WorldContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.server.management.UserListOpsEntry; +import net.minecraftforge.fml.common.FMLCommonHandler; import java.util.UUID; public class ForgePlayerContainer implements PlayerContainer { + private EntityPlayer sender; + public ForgePlayerContainer(EntityPlayer sender) { + this.sender = sender; } @Override @@ -26,7 +31,13 @@ public class ForgePlayerContainer implements PlayerContainer { @Override public boolean isOp() { - return false; + UserListOpsEntry userlistopsentry = FMLCommonHandler.instance().getMinecraftServerInstance() + .getPlayerList().getOppedPlayers().getEntry(this.sender.getGameProfile()); + if (userlistopsentry != null) { + return userlistopsentry.getPermissionLevel() >= 2; + } else { + return FMLCommonHandler.instance().getMinecraftServerInstance().getOpPermissionLevel() >= 2; + } } @Override diff --git a/src/main/java/com/sekwah/advancedportals/forge/effects/WarpEffectEnder.java b/src/main/java/com/sekwah/advancedportals/forge/effects/WarpEffectEnder.java new file mode 100644 index 00000000..7a467ebc --- /dev/null +++ b/src/main/java/com/sekwah/advancedportals/forge/effects/WarpEffectEnder.java @@ -0,0 +1,13 @@ +package com.sekwah.advancedportals.forge.effects; + +import com.sekwah.advancedportals.core.api.effect.WarpEffect; +import com.sekwah.advancedportals.core.api.portal.AdvancedPortal; +import com.sekwah.advancedportals.core.entities.PortalLocation; +import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; + +public class WarpEffectEnder extends WarpEffect { + @Override + protected void onWarp(PlayerContainer player, PortalLocation loc, Action action, Type type, AdvancedPortal portal) { + + } +} diff --git a/src/main/java/com/sekwah/advancedportals/spigot/effect/WarpEffectEnder.java b/src/main/java/com/sekwah/advancedportals/spigot/effect/WarpEffectEnder.java new file mode 100644 index 00000000..d6b03471 --- /dev/null +++ b/src/main/java/com/sekwah/advancedportals/spigot/effect/WarpEffectEnder.java @@ -0,0 +1,13 @@ +package com.sekwah.advancedportals.spigot.effect; + +import com.sekwah.advancedportals.core.api.effect.WarpEffect; +import com.sekwah.advancedportals.core.api.portal.AdvancedPortal; +import com.sekwah.advancedportals.core.entities.PortalLocation; +import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; + +public class WarpEffectEnder extends WarpEffect { + @Override + protected void onWarp(PlayerContainer player, PortalLocation loc, Action action, Type type, AdvancedPortal portal) { + + } +}