use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.
the class CmdSafeDelete method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (!(GeneralConfiguration.playersCanDeleteDimensions || sender.canUseCommand(3, getCommand()))) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "You have no permission to execute this command!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
if (args.length < 2) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "The dimension parameter is missing!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
} else if (args.length > 2) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
int dim = fetchInt(sender, args, 1, 0);
World world = sender.getEntityWorld();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
if (dimensionManager.getDimensionDescriptor(dim) == null) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Not an RFTools dimension!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
World w = DimensionManager.getWorld(dim);
if (w != null) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Dimension is still in use!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
if (!sender.canUseCommand(3, "safedel")) {
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
if (information.getOwner() == null) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "This dimension has no owner. You cannot delete it!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
if (!(sender instanceof EntityPlayerMP)) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "This command must be run as a player!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) sender;
if (!information.getOwner().equals(entityPlayerMP.getGameProfile().getId())) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "You are not the owner of this dimension. You cannot delete it!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
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));
ITextComponent component = new TextComponentString("Dimension deleted and dimension folder succesfully wiped!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
} catch (IOException e) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Dimension deleted but dimension folder could not be completely wiped!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
}
} else {
ITextComponent component = new TextComponentString("Dimension deleted. Please remove the dimension folder from disk!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
}
}
use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.
the class CmdSetOwner method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 3) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "The dimension and player parameters are missing!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
} else if (args.length > 3) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
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) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Not an RFTools dimension!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
return;
}
for (EntityPlayerMP entityPlayerMP : world.getMinecraftServer().getPlayerList().getPlayers()) {
if (playerName.equals(entityPlayerMP.getName())) {
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
information.setOwner(playerName, entityPlayerMP.getGameProfile().getId());
ITextComponent component = new TextComponentString(TextFormatting.GREEN + "Owner of dimension changed!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
dimensionManager.save(world);
return;
}
}
ITextComponent component = new TextComponentString(TextFormatting.RED + "Could not find player!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
}
use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.
the class GenericWorldGenerator method generateSpawnPlatform.
private void generateSpawnPlatform(World world) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.getDimension());
int midx = 8;
int midz = 8;
int starty;
if (information.getTerrainType() == TerrainType.TERRAIN_SOLID) {
starty = 64;
} else if (information.getTerrainType() == TerrainType.TERRAIN_INVERTIGO) {
starty = WorldGenerationTools.findUpsideDownEmptySpot(world, midx, midz);
} else {
starty = WorldGenerationTools.findSuitableEmptySpot(world, midx, midz);
}
if (starty == -1) {
// No suitable spot. We will carve something out.
starty = 64;
} else {
// Go one up
starty++;
}
boolean shelter = information.isShelter();
if (information.getTerrainType() == TerrainType.TERRAIN_LIQUID) {
shelter = true;
}
int bounds = 3;
if (shelter) {
bounds = 4;
}
for (int x = -bounds; x <= bounds; x++) {
for (int z = -bounds; z <= bounds; z++) {
if (x == 0 && z == 0) {
RFToolsDim.teleportationManager.createReceiver(world, new BlockPos(x + midx, starty, z + midz), information.getName(), -1);
} else if (x == 0 && (z == 2 || z == -2)) {
world.setBlockState(new BlockPos(x + midx, starty, z + midz), Blocks.GLOWSTONE.getDefaultState(), 3);
} else {
world.setBlockState(new BlockPos(x + midx, starty, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 18);
}
for (int y = 1; y <= 3; y++) {
world.setBlockToAir(new BlockPos(x + midx, starty + y, z + midz));
}
// Check the top layer. If it is something other then air we will replace it with clay as well.
if (!world.isAirBlock(new BlockPos(x + midx, starty + 4, z + midz))) {
world.setBlockState(new BlockPos(x + midx, starty + 4, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 18);
}
}
}
if (shelter) {
// The walls
for (int y = 1; y <= 3; y++) {
for (int x = -bounds; x <= bounds; x++) {
for (int z = -bounds; z <= bounds; z++) {
if (x == -bounds || x == bounds || z == -bounds || z == bounds) {
if (z == 0 && y >= 2 && y <= 3 || x == 0 && y >= 2 && y <= 3 && z == bounds) {
world.setBlockState(new BlockPos(x + midx, starty + y, z + midz), Blocks.GLASS_PANE.getStateFromMeta(0), 18);
} else if (x == 0 && y == 1 && z == -bounds) {
world.setBlockState(new BlockPos(x + midx, starty + y, z + midz), Blocks.IRON_DOOR.getStateFromMeta(1), 18);
} else if (x == 0 && y == 2 && z == -bounds) {
world.setBlockState(new BlockPos(x + midx, starty + y, z + midz), Blocks.IRON_DOOR.getStateFromMeta(8), 18);
} else {
world.setBlockState(new BlockPos(x + midx, starty + y, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(9), 18);
}
}
}
}
}
// The roof
for (int x = -bounds; x <= bounds; x++) {
for (int z = -bounds; z <= bounds; z++) {
world.setBlockState(new BlockPos(x + midx, starty + 4, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(9), 18);
}
}
// The pad outside the door
for (int x = -1; x <= 1; ++x) {
for (int z = -bounds - 2; z <= -bounds - 1; ++z) {
world.setBlockState(new BlockPos(x + midx, starty, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 18);
for (int y = 1; y <= 3; y++) {
world.setBlockToAir(new BlockPos(x + midx, starty + y, z + midz));
}
// Check the top layer. If it is something other then air we will replace it with clay as well.
if (!world.isAirBlock(new BlockPos(x + midx, starty + 4, z + midz))) {
world.setBlockState(new BlockPos(x + midx, starty + 4, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(9), 18);
}
}
}
// The buttons to open the door
world.setBlockState(new BlockPos(midx - 1, starty + 2, midz - bounds - 1), Blocks.STONE_BUTTON.getStateFromMeta(4), 18);
world.setBlockState(new BlockPos(midx + 1, starty + 2, midz - bounds + 1), Blocks.STONE_BUTTON.getStateFromMeta(3), 18);
}
registerReceiver(world, dimensionManager, information, midx, midz, starty);
}
use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.
the class RealizedDimensionTab method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(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.DimensionInformation in project RFToolsDimensions by McJty.
the class DimensionSyncPacket method consumePacket.
public void consumePacket(ByteBuf data) {
int size = data.readInt();
for (int i = 0; i < size; i++) {
int id = data.readInt();
PacketBuffer buffer = new PacketBuffer(data);
NBTTagCompound tagCompound;
try {
tagCompound = buffer.readCompoundTag();
} catch (IOException e) {
e.printStackTrace();
return;
}
DimensionDescriptor descriptor = new DimensionDescriptor(tagCompound);
dimensions.put(id, descriptor);
}
size = data.readInt();
for (int i = 0; i < size; i++) {
int id = data.readInt();
String name = NetworkTools.readString(data);
DimensionInformation dimInfo = new DimensionInformation(name, dimensions.get(id), data);
dimensionInformation.put(id, dimInfo);
}
}
Aggregations