use of mcjty.rftoolsdim.dimensions.DimensionStorage 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.DimensionStorage 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.DimensionStorage in project RFToolsDimensions by McJty.
the class GenericWorldProvider method getRespawnDimension.
@Override
public int getRespawnDimension(EntityPlayerMP player) {
getDimensionInformation();
if (GeneralConfiguration.respawnSameDim || (dimensionInformation != null && dimensionInformation.isRespawnHere())) {
DimensionStorage dimensionStorage = getStorage();
int power = dimensionStorage.getEnergyLevel(getDimension());
if (power < 1000) {
return GeneralConfiguration.spawnDimension;
} else {
return getDimension();
}
}
return GeneralConfiguration.spawnDimension;
}
use of mcjty.rftoolsdim.dimensions.DimensionStorage in project RFToolsDimensions by McJty.
the class CmdListDimensions method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
WorldServer[] worlds = DimensionManager.getWorlds();
for (WorldServer world : worlds) {
int id = world.provider.getDimension();
String dimName = world.provider.getDimensionType().getName();
ChatTools.addChatMessage(sender, new TextComponentString(" Loaded: id:" + id + ", " + dimName));
}
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(sender.getEntityWorld());
DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(sender.getEntityWorld());
for (Map.Entry<Integer, DimensionDescriptor> me : dimensionManager.getDimensions().entrySet()) {
int id = me.getKey();
DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
String dimName = dimensionInformation.getName();
int energy = dimensionStorage.getEnergyLevel(id);
String ownerName = dimensionInformation.getOwnerName();
if (ownerName != null && !ownerName.isEmpty()) {
ChatTools.addChatMessage(sender, new TextComponentString(" RfTools: id:" + id + ", " + dimName + " (power " + energy + ") (owner " + ownerName + ")"));
} else {
ChatTools.addChatMessage(sender, new TextComponentString(" RfTools: id:" + id + ", " + dimName + " (power " + energy + ")"));
}
}
}
use of mcjty.rftoolsdim.dimensions.DimensionStorage in project RFToolsDimensions by McJty.
the class CmdSetPower method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length > 2) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Too many parameters!"));
return;
}
int rf = fetchInt(sender, args, 1, PowerConfiguration.MAX_DIMENSION_POWER);
World world = sender.getEntityWorld();
int 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;
}
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
storage.setEnergyLevel(dim, rf);
storage.save(world);
}
Aggregations