use of mcjty.rftools.dimension.RfToolsDimensionManager 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)));
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager 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"));
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class CmdReclaim method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension parameters 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();
if (DimensionManager.isDimensionRegistered(dim)) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This dimension is still in use! You can't reclaim the id!"));
return;
}
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
dimensionManager.reclaimId(dim);
dimensionManager.save(world);
sender.addChatMessage(new ChatComponentText("Dimension id " + dim + " reclaimed for future use."));
}
use of mcjty.rftools.dimension.RfToolsDimensionManager 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!"));
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class SyncDimensionInfoHelper method syncDimensionManagerFromServer.
public static void syncDimensionManagerFromServer(PacketSyncDimensionInfo message) {
World world = Minecraft.getMinecraft().theWorld;
System.out.println("SYNC DIMENSION STUFF: world.isRemote = " + world.isRemote);
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
dimensionManager.syncFromServer(message.getDimensions(), message.getDimensionInformation());
dimensionManager.save(world);
}
Aggregations