Search in sources :

Example 31 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class CmdInfo method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    int dim = 0;
    World world = sender.getEntityWorld();
    if (args.length == 2) {
        dim = fetchInt(sender, args, 1, 0);
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    } else {
        dim = world.provider.dimensionId;
    }
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Dimension ID " + dim));
    sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Description string " + information.getDescriptor().getDescriptionString()));
    String ownerName = information.getOwnerName();
    if (ownerName != null && !ownerName.isEmpty()) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Owned by: " + ownerName));
    }
    if (sender instanceof EntityPlayer) {
        information.dump((EntityPlayer) sender);
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 32 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class CmdListEffects method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    World world = sender.getEntityWorld();
    int dim = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    for (EffectType type : information.getEffectTypes()) {
        sender.addChatMessage(new ChatComponentText("    Effect: " + type.toString().substring(7)));
    }
}
Also used : World(net.minecraft.world.World) EffectType(mcjty.rftools.dimension.world.types.EffectType) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) ChatComponentText(net.minecraft.util.ChatComponentText) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 33 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class CmdRecover method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    World world = sender.getEntityWorld();
    ItemStack heldItem = null;
    String playerName = null;
    UUID playerUUID = null;
    if (sender instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) sender;
        heldItem = player.getHeldItem();
        playerName = player.getDisplayName();
        playerUUID = player.getGameProfile().getId();
    }
    if (heldItem == null || heldItem.getItem() != DimletSetup.realizedDimensionTab) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You need to hold a realized dimension tab in your hand!"));
        return;
    }
    int specifiedDim = -1;
    if (args.length == 2) {
        specifiedDim = fetchInt(sender, args, 1, -1);
    }
    NBTTagCompound tagCompound = heldItem.getTagCompound();
    int dim = tagCompound.getInteger("id");
    if ((!tagCompound.hasKey("id")) || dim == 0 || dim == -1) {
        if (specifiedDim == -1) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension id is missing from the tab!"));
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You can specify a dimension id manually"));
            return;
        } else {
            dim = specifiedDim;
        }
    }
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information != null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension information is already present!"));
        return;
    }
    if (DimensionManager.isDimensionRegistered(dim)) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This dimension is already registered!"));
        return;
    }
    DimensionDescriptor descriptor = new DimensionDescriptor(tagCompound);
    String name = tagCompound.getString("name");
    dimensionManager.recoverDimension(world, dim, descriptor, name, playerName, playerUUID);
    sender.addChatMessage(new ChatComponentText("Dimension was succesfully recovered"));
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) UUID(java.util.UUID) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 34 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class CmdSafeDelete method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension parameter is missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionDescriptor(dim) == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    World w = DimensionManager.getWorld(dim);
    if (w != null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Dimension is still in use!"));
        return;
    }
    if (!sender.canCommandSenderUseCommand(3, "safedel")) {
        DimensionInformation information = dimensionManager.getDimensionInformation(dim);
        if (information.getOwner() == null) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This dimension has no owner. You cannot delete it!"));
            return;
        }
        if (!(sender instanceof EntityPlayerMP)) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This command must be run as a player!"));
            return;
        }
        EntityPlayerMP entityPlayerMP = (EntityPlayerMP) sender;
        if (!information.getOwner().equals(entityPlayerMP.getGameProfile().getId())) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You are not the owner of this dimension. You cannot delete it!"));
            return;
        }
    }
    TeleportDestinations destinations = TeleportDestinations.getDestinations(world);
    destinations.removeDestinationsInDimension(dim);
    destinations.save(world);
    dimensionManager.removeDimension(dim);
    dimensionManager.reclaimId(dim);
    dimensionManager.save(world);
    DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
    dimensionStorage.removeDimension(dim);
    dimensionStorage.save(world);
    if (DimletConfiguration.dimensionFolderIsDeletedWithSafeDel) {
        File rootDirectory = DimensionManager.getCurrentSaveRootDirectory();
        try {
            FileUtils.deleteDirectory(new File(rootDirectory.getPath() + File.separator + "DIM" + dim));
            sender.addChatMessage(new ChatComponentText("Dimension deleted and dimension folder succesfully wiped!"));
        } catch (IOException e) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Dimension deleted but dimension folder could not be completely wiped!"));
        }
    } else {
        sender.addChatMessage(new ChatComponentText("Dimension deleted. Please remove the dimension folder from disk!"));
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) TeleportDestinations(mcjty.rftools.blocks.teleporter.TeleportDestinations) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IOException(java.io.IOException) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) File(java.io.File) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 35 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class CmdAddEffect method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Several parameters are missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    String effectName = fetchString(sender, args, 1, "");
    effectName = "EFFECT_" + effectName.toUpperCase();
    EffectType type = null;
    try {
        type = EffectType.valueOf(effectName);
    } catch (IllegalArgumentException e) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Bad effect name!"));
        return;
    }
    World world = sender.getEntityWorld();
    int dim = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    information.getEffectTypes().add(type);
    dimensionManager.save(world);
}
Also used : EffectType(mcjty.rftools.dimension.world.types.EffectType) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Aggregations

DimensionInformation (mcjty.rftools.dimension.DimensionInformation)35 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)29 World (net.minecraft.world.World)19 ChatComponentText (net.minecraft.util.ChatComponentText)13 DimensionStorage (mcjty.rftools.dimension.DimensionStorage)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)8 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)5 IOException (java.io.IOException)4 DimensionDescriptor (mcjty.rftools.dimension.description.DimensionDescriptor)4 ItemStack (net.minecraft.item.ItemStack)4 File (java.io.File)3 EffectType (mcjty.rftools.dimension.world.types.EffectType)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 Map (java.util.Map)2 Coordinate (mcjty.lib.varia.Coordinate)2 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)2 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)2 PacketGetDimensionEnergy (mcjty.rftools.dimension.network.PacketGetDimensionEnergy)2 IMob (net.minecraft.entity.monster.IMob)2