Added the basics of opped code to forge
This commit is contained in:
parent
9d59bf3d54
commit
a9b9c89422
|
@ -9,7 +9,7 @@ import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
*/
|
*/
|
||||||
public class TestEffect extends WarpEffect {
|
public class TestEffect extends WarpEffect {
|
||||||
@Override
|
@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 {
|
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 {
|
public enum Action {
|
||||||
ENTER,
|
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;
|
this.commandExecutor = commandExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRequiredPermissionLevel() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkPermission(MinecraftServer p_checkPermission_1_, ICommandSender p_checkPermission_2_) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return commandName;
|
return commandName;
|
||||||
|
|
|
@ -4,7 +4,9 @@ import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer
|
||||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
import net.minecraft.command.ICommandSender;
|
import net.minecraft.command.ICommandSender;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.server.management.UserListOpsEntry;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.TextComponentString;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
|
|
||||||
public class ForgeCommandSenderContainer implements CommandSenderContainer {
|
public class ForgeCommandSenderContainer implements CommandSenderContainer {
|
||||||
private final ICommandSender sender;
|
private final ICommandSender sender;
|
||||||
|
@ -20,7 +22,26 @@ public class ForgeCommandSenderContainer implements CommandSenderContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOp() {
|
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
|
@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.PlayerContainer;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.WorldContainer;
|
import com.sekwah.advancedportals.coreconnector.container.WorldContainer;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.server.management.UserListOpsEntry;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ForgePlayerContainer implements PlayerContainer {
|
public class ForgePlayerContainer implements PlayerContainer {
|
||||||
|
|
||||||
|
private EntityPlayer sender;
|
||||||
|
|
||||||
public ForgePlayerContainer(EntityPlayer sender) {
|
public ForgePlayerContainer(EntityPlayer sender) {
|
||||||
|
|
||||||
|
this.sender = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +31,13 @@ public class ForgePlayerContainer implements PlayerContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOp() {
|
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
|
@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