Added the basics of opped code to forge

This commit is contained in:
Sekwah 2018-07-19 02:55:59 +01:00 committed by Sekwah
parent c88b6f3b9d
commit 6593f21bed
8 changed files with 79 additions and 4 deletions

View File

@ -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) {
}
}

View File

@ -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,

View File

@ -0,0 +1,7 @@
package com.sekwah.advancedportals.coreconnector.container;
public interface ServerContainer {
WorldContainer getWorld(String name);
}

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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) {
}
}

View File

@ -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) {
}
}