Last active
February 21, 2016 22:39
-
-
Save gabizou/7771293f877786461538 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.voxelplugineering.voxelsniper.brush.mask; | |
| import com.voxelplugineering.voxelsniper.brush.Brush; | |
| import com.voxelplugineering.voxelsniper.brush.BrushInfo; | |
| import com.voxelplugineering.voxelsniper.brush.BrushKeys; | |
| import com.voxelplugineering.voxelsniper.brush.BrushParam; | |
| import com.voxelplugineering.voxelsniper.brush.BrushPartType; | |
| import com.voxelplugineering.voxelsniper.brush.BrushVars; | |
| import com.voxelplugineering.voxelsniper.brush.ExecutionResult; | |
| import com.voxelplugineering.voxelsniper.config.VoxelSniperConfiguration; | |
| import com.voxelplugineering.voxelsniper.entity.EntityType; | |
| import com.voxelplugineering.voxelsniper.entity.Player; | |
| import com.voxelplugineering.voxelsniper.util.math.Vector3d; | |
| import com.voxelplugineering.voxelsniper.world.Block; | |
| import com.voxelplugineering.voxelsniper.world.queue.EntityChangeQueue; | |
| import java.util.Optional; | |
| // TODO add disc based spawning area to choose from. | |
| @BrushInfo(name = "entity", | |
| type = BrushPartType.MISC, | |
| params = {@BrushParam(name = BrushKeys.ENTITY_TYPE, desc = "The entity type to spawn"), | |
| @BrushParam(name = BrushKeys.ENTITY_COUNT, desc = "The amount of entities")}, | |
| permission = "voxelsniper.brush.entity") | |
| public class EntityBrush extends Brush { | |
| @Override | |
| public ExecutionResult run(Player player, BrushVars args) { | |
| final double size = args.get(BrushKeys.BRUSH_SIZE, Double.class).get(); | |
| Optional<EntityType> entityType = args.get(BrushKeys.ENTITY_TYPE, EntityType.class); | |
| if (!entityType.isPresent()) { | |
| player.sendMessage(VoxelSniperConfiguration.missingEntity, "RANDOM"); | |
| return ExecutionResult.abortExecution(); | |
| } | |
| final int count = args.get(BrushKeys.ENTITY_COUNT, Integer.class).orElse(1); | |
| final Optional<Block> vector3d = args.get(BrushKeys.TARGET_BLOCK, Block.class); | |
| final Vector3d position = vector3d.get().getLocation().toVector(); | |
| new EntityChangeQueue(player, player.getWorld(), entityType.get(), position, count, size).flush(); | |
| return ExecutionResult.continueExecution(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment