use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class RealizedDimensionTab method clOnItemRightClick.
@Override
protected ActionResult<ItemStack> clOnItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if ((!world.isRemote) && player.isSneaking()) {
NBTTagCompound tagCompound = stack.getTagCompound();
Logging.message(player, tagCompound.getString("descriptionString"));
int id = tagCompound.getInteger("id");
if (id != 0) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(id);
if (information != null) {
information.dump(player);
}
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class DimensionMonitorItem method clOnItemRightClick.
@Override
protected ActionResult<ItemStack> clOnItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote) {
int id = player.getEntityWorld().provider.getDimension();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.getEntityWorld());
DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
if (dimensionInformation == null) {
Logging.message(player, "Not an RFTools dimension!");
} else {
String name = dimensionInformation.getName();
DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
int power = storage != null ? storage.getEnergyLevel(id) : 0;
Logging.message(player, TextFormatting.BLUE + "Name: " + name + " (Id " + id + ")" + TextFormatting.YELLOW + " Power: " + power + " RF");
if (player.isSneaking()) {
Logging.message(player, TextFormatting.RED + "Description: " + dimensionInformation.getDescriptor().getDescriptionString());
System.out.println("Description: = " + dimensionInformation.getDescriptor().getDescriptionString());
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class CmdSafeDelete method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (!(GeneralConfiguration.playersCanDeleteDimensions || CompatCommandBase.canUseCommand(sender, 3, getCommand()))) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "You have no permission to execute this command!"));
return;
}
if (args.length < 2) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "The dimension parameter is missing!"));
return;
} else if (args.length > 2) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.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) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Not an RFTools dimension!"));
return;
}
World w = DimensionManager.getWorld(dim);
if (w != null) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Dimension is still in use!"));
return;
}
if (!CompatCommandBase.canUseCommand(sender, 3, "safedel")) {
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
if (information.getOwner() == null) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "This dimension has no owner. You cannot delete it!"));
return;
}
if (!(sender instanceof EntityPlayerMP)) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "This command must be run as a player!"));
return;
}
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) sender;
if (!information.getOwner().equals(entityPlayerMP.getGameProfile().getId())) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "You are not the owner of this dimension. You cannot delete it!"));
return;
}
}
RFToolsDim.teleportationManager.removeReceiverDestinations(world, dim);
dimensionManager.removeDimension(dim);
dimensionManager.reclaimId(dim);
dimensionManager.save(world);
DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
dimensionStorage.removeDimension(dim);
dimensionStorage.save(world);
if (GeneralConfiguration.dimensionFolderIsDeletedWithSafeDel) {
File rootDirectory = DimensionManager.getCurrentSaveRootDirectory();
try {
FileUtils.deleteDirectory(new File(rootDirectory.getPath() + File.separator + "RFTOOLS" + dim));
ChatTools.addChatMessage(sender, new TextComponentString("Dimension deleted and dimension folder succesfully wiped!"));
} catch (IOException e) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Dimension deleted but dimension folder could not be completely wiped!"));
}
} else {
ChatTools.addChatMessage(sender, new TextComponentString("Dimension deleted. Please remove the dimension folder from disk!"));
}
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class CmdSetOwner method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 3) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "The dimension and player parameters are missing!"));
return;
} else if (args.length > 3) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Too many parameters!"));
return;
}
int dim = fetchInt(sender, args, 1, 0);
String playerName = fetchString(sender, args, 2, null);
World world = sender.getEntityWorld();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
if (dimensionManager.getDimensionDescriptor(dim) == null) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Not an RFTools dimension!"));
return;
}
for (EntityPlayerMP entityPlayerMP : WorldTools.getPlayerList((WorldServer) world)) {
if (playerName.equals(entityPlayerMP.getDisplayName())) {
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
information.setOwner(playerName, entityPlayerMP.getGameProfile().getId());
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.GREEN + "Owner of dimension changed!"));
dimensionManager.save(world);
return;
}
}
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Could not find player!"));
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions 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) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Too many parameters!"));
return;
} else {
dim = world.provider.getDimension();
}
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
if (information == null) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Not an RFTools dimension!"));
return;
}
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.YELLOW + "Dimension ID " + dim));
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.YELLOW + "Description string " + information.getDescriptor().getDescriptionString()));
String ownerName = information.getOwnerName();
if (ownerName != null && !ownerName.isEmpty()) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.YELLOW + "Owned by: " + ownerName));
}
if (sender instanceof EntityPlayer) {
information.dump((EntityPlayer) sender);
}
}
Aggregations