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);
}
}
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)));
}
}
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"));
}
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!"));
}
}
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);
}
Aggregations