Skip to content

Commit

Permalink
Implements #291 with the new command system
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelien30000 committed Sep 9, 2023
1 parent 14dc946 commit b5d8b3b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cloud.commandframework.annotations.Argument;
import cloud.commandframework.annotations.CommandMethod;
import cloud.commandframework.annotations.CommandPermission;
import cloud.commandframework.annotations.specifier.Liberal;
import cloud.commandframework.annotations.specifier.Range;
import com.fastasyncworldedit.core.configuration.Caption;
import com.sk89q.worldedit.math.BlockVector3;
Expand All @@ -18,6 +19,7 @@
import com.thevoxelbox.voxelsniper.util.material.MaterialSet;
import com.thevoxelbox.voxelsniper.util.material.MaterialSets;
import com.thevoxelbox.voxelsniper.util.material.Materials;
import com.thevoxelbox.voxelsniper.util.message.VoxelSniperText;
import org.bukkit.util.Vector;
import org.bukkit.util.noise.PerlinNoiseGenerator;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -54,11 +56,11 @@ public class HeatRayBrush extends AbstractBrush {
.with(BlockCategories.WOODEN_FENCES)
.with(BlockCategories.FENCE_GATES)
.with(BlockCategories.SNOW)
.with(BlockCategories.FIRE)
.with(MaterialSets.TORCHES)
.with(MaterialSets.FLORA)
.add(BlockTypes.SPONGE)
.add(BlockTypes.COBWEB)
.add(BlockTypes.FIRE)
.add(BlockTypes.LADDER)
.build();

Expand All @@ -67,6 +69,7 @@ public class HeatRayBrush extends AbstractBrush {
private double requiredFireDensity;
private double requiredAirDensity;

private boolean soulFire;
private int octaves;
private double frequency;
private double amplitude;
Expand Down Expand Up @@ -97,6 +100,20 @@ public void onBrushInfo(
super.onBrushInfoCommand(snipe, Caption.of("voxelsniper.brush.heat-ray.info"));
}

@CommandMethod("<soul-fire>")
public void onBrushSoulfire(
final @NotNull Snipe snipe,
final @Argument("soul-fire") @Liberal boolean soulFire
) {
this.soulFire = soulFire;

SnipeMessenger messenger = snipe.createMessenger();
messenger.sendMessage(Caption.of(
"voxelsniper.brush.heat-ray.set-soul-fire",
VoxelSniperText.getStatus(this.soulFire)
));
}

@CommandMethod("oct <octaves>")
public void onBrushOct(
final @NotNull Snipe snipe,
Expand Down Expand Up @@ -159,6 +176,7 @@ public void heatRay(Snipe snipe) {
Vector targetBlockVector = Vectors.toBukkit(targetBlock);
Vector currentLocation = new Vector();
int brushSize = toolkitProperties.getBrushSize();
BlockType fire = soulFire ? BlockTypes.SOUL_FIRE : BlockTypes.FIRE;
for (int z = brushSize; z >= -brushSize; z--) {
for (int x = brushSize; x >= -brushSize; x--) {
for (int y = brushSize; y >= -brushSize; y--) {
Expand Down Expand Up @@ -190,7 +208,7 @@ public void heatRay(Snipe snipe) {
currentLocation.getBlockX(),
currentLocation.getBlockY(),
currentLocation.getBlockZ(),
BlockTypes.FIRE
fire
);
continue;
}
Expand Down Expand Up @@ -246,12 +264,12 @@ public void heatRay(Snipe snipe) {
);
}
} else if (fireDensity >= this.requiredFireDensity) {
if (currentBlockType != BlockTypes.FIRE) {
if (currentBlockType != fire) {
setBlock(
currentLocation.getBlockX(),
currentLocation.getBlockY(),
currentLocation.getBlockZ(),
BlockTypes.FIRE
fire
);
}
} else if (airDensity >= this.requiredAirDensity) {
Expand All @@ -274,6 +292,10 @@ public void sendInfo(Snipe snipe) {
snipe.createMessageSender()
.brushNameMessage()
.brushSizeMessage()
.message(Caption.of(
"voxelsniper.brush.heat-ray.set-soul-fire",
VoxelSniperText.getStatus(this.soulFire)
))
.message(Caption.of(
"voxelsniper.brush.heat-ray.set-octaves",
this.octaves
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
"voxelsniper.brush.generate-tree.set-maximum-leaf-thickness": "&9Maximum Leaf Thickness set to: &f{0}",

"voxelsniper.brush.heat-ray.info": "&6Heat Ray Brush Parameters:\n&b/b hr oct [n] -- Sets octave parameter to n for the noise generator.\n&b/b hr amp [n] -- Sets amplitude parameter to n for the noise generator.\n&b/b hr freq [n] -- Sets frequency parameter to n for the noise generator.",
"voxelsniper.brush.heat-ray.set-soul-fire": "&bSoul fire mode is {0}",
"voxelsniper.brush.heat-ray.set-octaves": "&aOctaves set to: &f{0}",
"voxelsniper.brush.heat-ray.set-amplitude": "&aAmplitude set to: &f{0}",
"voxelsniper.brush.heat-ray.set-frequency": "&aFrequency set to: &f{0}",
Expand Down

0 comments on commit b5d8b3b

Please sign in to comment.