mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-12-23 17:38:34 +01:00
Added the basics of opped code to forge
This commit is contained in:
parent
c88b6f3b9d
commit
6593f21bed
@ -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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.sekwah.advancedportals.coreconnector.container;
|
||||
|
||||
public interface ServerContainer {
|
||||
|
||||
WorldContainer getWorld(String name);
|
||||
|
||||
}
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user