use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class CmdSetOwner method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension and player parameters are missing!"));
return;
} else if (args.length > 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.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) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
return;
}
for (Object o : MinecraftServer.getServer().getConfigurationManager().playerEntityList) {
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) o;
if (playerName.equals(entityPlayerMP.getDisplayName())) {
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
information.setOwner(playerName, entityPlayerMP.getGameProfile().getId());
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Owner of dimension changed!"));
dimensionManager.save(world);
return;
}
}
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not find player!"));
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class CmdSetPower method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length > 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
}
int rf = fetchInt(sender, args, 1, DimletConfiguration.MAX_DIMENSION_POWER);
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;
}
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
storage.setEnergyLevel(dim, rf);
storage.save(world);
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class CmdSaveDim method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension and filename parameters are missing!"));
return;
} else if (args.length > 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
}
int dim = fetchInt(sender, args, 1, 0);
String filename = fetchString(sender, args, 2, null);
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;
}
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
String error = information.buildJson(filename);
if (error != null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Error: " + error));
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class PacketGetAllReceivers method addRfToolsDimensions.
private void addRfToolsDimensions(World world, List<TeleportDestinationClientInfo> destinationList) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
for (Map.Entry<Integer, DimensionDescriptor> me : dimensionManager.getDimensions().entrySet()) {
int id = me.getKey();
TeleportDestination destination = new TeleportDestination(new Coordinate(0, 70, 0), id);
destination.setName("RfTools Dim: " + id);
TeleportDestinationClientInfo teleportDestinationClientInfo = new TeleportDestinationClientInfo(destination);
destinationList.add(teleportDestinationClientInfo);
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class ForgeEventHandlers method onAttackEntityEvent.
@SubscribeEvent
public void onAttackEntityEvent(AttackEntityEvent event) {
World world = event.entityPlayer.getEntityWorld();
int id = world.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
if (dimensionManager.getDimensionInformation(id) != null) {
// RFTools dimension.
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
int energy = storage.getEnergyLevel(id);
if (energy <= 0) {
event.setCanceled(true);
}
}
}
Aggregations