Dieser Commit ist enthalten in:
Jesse Boyd 2019-04-20 00:47:32 +10:00
Commit c56ba112d1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
162 geänderte Dateien mit 3646 neuen und 7453 gelöschten Zeilen

Datei anzeigen

@ -47,7 +47,7 @@ ext {
date = git.head().getDate().format("yy.MM.dd") date = git.head().getDate().format("yy.MM.dd")
revision = "-${git.head().abbreviatedId}" revision = "-${git.head().abbreviatedId}"
parents = git.head().parentIds; parents = git.head().parentIds;
index = -2115; // Offset to match CI index = -2116; // Offset to match CI
for (; parents != null && !parents.isEmpty(); index++) { for (; parents != null && !parents.isEmpty(); index++) {
parents = git.getResolve().toCommit(parents.get(0)).getParentIds() parents = git.getResolve().toCommit(parents.get(0)).getParentIds()
} }
@ -59,7 +59,7 @@ if ( project.hasProperty("lzNoVersion") ) { // gradle build -PlzNoVersion
} else { } else {
version = String.format("%s.%s", rootVersion, buildNumber) version = String.format("%s.%s", rootVersion, buildNumber)
} }
description = """FastAsyncWorldEdit""" description = rootProject.name
subprojects { subprojects {
apply plugin: 'java' apply plugin: 'java'
@ -68,8 +68,6 @@ subprojects {
// Enable this requires putting license header files in many, many FAWE files // Enable this requires putting license header files in many, many FAWE files
//apply plugin: 'net.minecrell.licenser' //apply plugin: 'net.minecrell.licenser'
ext.internalVersion = version
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8

Datei anzeigen

@ -1,10 +1,6 @@
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven' apply plugin: 'maven'
repositories {
maven {url "https://ci.athion.net/job/FAWE-WorldGuard-1.13/lastSuccessfulBuild/artifact/mvn"}
}
dependencies { dependencies {
compile project(':worldedit-bukkit') compile project(':worldedit-bukkit')
compile 'com.martiansoftware:jsap:2.1' compile 'com.martiansoftware:jsap:2.1'

Datei anzeigen

@ -13,21 +13,18 @@ import java.util.Set;
/** /**
* Brush registration manager. * Brush registration manager.
*/ */
public class Brushes public class Brushes {
{
private Multimap<Class<? extends IBrush>, String> brushes = HashMultimap.create(); private Multimap<Class<? extends IBrush>, String> brushes = HashMultimap.create();
/** /**
* Register a brush for VoxelSniper to be able to use. * Register a brush for VoxelSniper to be able to use.
* *
* @param clazz Brush implementing IBrush interface. * @param clazz Brush implementing IBrush interface.
* @param handles Handles under which the brush can be accessed ingame. * @param handles Handles under which the brush can be accessed ingame.
*/ */
public void registerSniperBrush(Class<? extends IBrush> clazz, String... handles) public void registerSniperBrush(Class<? extends IBrush> clazz, String... handles) {
{
Preconditions.checkNotNull(clazz, "Cannot register null as a class."); Preconditions.checkNotNull(clazz, "Cannot register null as a class.");
for (String handle : handles) for (String handle : handles) {
{
brushes.put(clazz, handle.toLowerCase()); brushes.put(clazz, handle.toLowerCase());
} }
} }
@ -38,18 +35,14 @@ public class Brushes
* @param handle Case insensitive brush handle * @param handle Case insensitive brush handle
* @return Brush class * @return Brush class
*/ */
public Class<? extends IBrush> getBrushForHandle(String handle) public Class<? extends IBrush> getBrushForHandle(String handle) {
{
Preconditions.checkNotNull(handle, "Brushhandle can not be null."); Preconditions.checkNotNull(handle, "Brushhandle can not be null.");
if (!brushes.containsValue(handle.toLowerCase())) if (!brushes.containsValue(handle.toLowerCase())) {
{
return null; return null;
} }
for (Map.Entry<Class<? extends IBrush>, String> entry : brushes.entries()) for (Map.Entry<Class<? extends IBrush>, String> entry : brushes.entries()) {
{ if (entry.getValue().equalsIgnoreCase(handle)) {
if (entry.getValue().equalsIgnoreCase(handle))
{
return entry.getKey(); return entry.getKey();
} }
} }
@ -59,34 +52,29 @@ public class Brushes
/** /**
* @return Amount of IBrush classes registered with the system under Sniper visibility. * @return Amount of IBrush classes registered with the system under Sniper visibility.
*/ */
public int registeredSniperBrushes() public int registeredSniperBrushes() {
{
return brushes.keySet().size(); return brushes.keySet().size();
} }
/** /**
* @return Amount of handles registered with the system under Sniper visibility. * @return Amount of handles registered with the system under Sniper visibility.
*/ */
public int registeredSniperBrushHandles() public int registeredSniperBrushHandles() {
{
return brushes.size(); return brushes.size();
} }
/** /**
*
* @param clazz Brush class * @param clazz Brush class
* @return All Sniper registered handles for the brush. * @return All Sniper registered handles for the brush.
*/ */
public Set<String> getSniperBrushHandles(Class<? extends IBrush> clazz) public Set<String> getSniperBrushHandles(Class<? extends IBrush> clazz) {
{
return new HashSet<>(brushes.get(clazz)); return new HashSet<>(brushes.get(clazz));
} }
/** /**
* @return Immutable Multimap copy of all the registered brushes * @return Immutable Multimap copy of all the registered brushes
*/ */
public Multimap<Class<?extends IBrush>, String> getRegisteredBrushesMultimap() public Multimap<Class<? extends IBrush>, String> getRegisteredBrushesMultimap() {
{
return ImmutableMultimap.copyOf(brushes); return ImmutableMultimap.copyOf(brushes);
} }
} }

Datei anzeigen

@ -1,23 +1,19 @@
package com.thevoxelbox.voxelsniper; package com.thevoxelbox.voxelsniper;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
/** /**
* *
*/ */
public class Message public class Message {
{
private static final int BRUSH_SIZE_WARNING_THRESHOLD = 20; private static final int BRUSH_SIZE_WARNING_THRESHOLD = 20;
private final SnipeData snipeData; private final SnipeData snipeData;
/** /**
* @param snipeData * @param snipeData
*/ */
public Message(SnipeData snipeData) public Message(SnipeData snipeData) {
{
this.snipeData = snipeData; this.snipeData = snipeData;
} }
@ -26,8 +22,7 @@ public class Message
* *
* @param brushMessage * @param brushMessage
*/ */
public void brushMessage(String brushMessage) public void brushMessage(String brushMessage) {
{
snipeData.sendMessage(ChatColor.LIGHT_PURPLE + brushMessage); snipeData.sendMessage(ChatColor.LIGHT_PURPLE + brushMessage);
} }
@ -36,16 +31,14 @@ public class Message
* *
* @param brushName * @param brushName
*/ */
public void brushName(String brushName) public void brushName(String brushName) {
{
snipeData.sendMessage(ChatColor.AQUA + "Brush Type: " + ChatColor.LIGHT_PURPLE + brushName); snipeData.sendMessage(ChatColor.AQUA + "Brush Type: " + ChatColor.LIGHT_PURPLE + brushName);
} }
/** /**
* Display Center Parameter. * Display Center Parameter.
*/ */
public void center() public void center() {
{
snipeData.sendMessage(ChatColor.DARK_BLUE + "Brush Center: " + ChatColor.DARK_RED + snipeData.getcCen()); snipeData.sendMessage(ChatColor.DARK_BLUE + "Brush Center: " + ChatColor.DARK_RED + snipeData.getcCen());
} }
@ -54,24 +47,21 @@ public class Message
* *
* @param message * @param message
*/ */
public void custom(String message) public void custom(String message) {
{
snipeData.sendMessage(message); snipeData.sendMessage(message);
} }
/** /**
* Display data value. * Display data value.
*/ */
public void data() public void data() {
{
snipeData.sendMessage(ChatColor.BLUE + "Data Variable: " + ChatColor.DARK_RED + snipeData.getPropertyId()); snipeData.sendMessage(ChatColor.BLUE + "Data Variable: " + ChatColor.DARK_RED + snipeData.getPropertyId());
} }
/** /**
* Display voxel height. * Display voxel height.
*/ */
public void height() public void height() {
{
snipeData.sendMessage(ChatColor.DARK_AQUA + "Brush Height: " + ChatColor.DARK_RED + snipeData.getVoxelHeight()); snipeData.sendMessage(ChatColor.DARK_AQUA + "Brush Height: " + ChatColor.DARK_RED + snipeData.getVoxelHeight());
} }
@ -80,8 +70,7 @@ public class Message
* *
* @param performerName * @param performerName
*/ */
public void performerName(String performerName) public void performerName(String performerName) {
{
this.snipeData.sendMessage(ChatColor.DARK_PURPLE + "Performer: " + ChatColor.DARK_GREEN + performerName); this.snipeData.sendMessage(ChatColor.DARK_PURPLE + "Performer: " + ChatColor.DARK_GREEN + performerName);
} }
@ -89,27 +78,23 @@ public class Message
* Displaye replace material. * Displaye replace material.
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void replace() public void replace() {
{
snipeData.sendMessage(ChatColor.AQUA + "Replace Material: " + BlockTypes.get(snipeData.getReplaceId())); snipeData.sendMessage(ChatColor.AQUA + "Replace Material: " + BlockTypes.get(snipeData.getReplaceId()));
} }
/** /**
* Display replace data value. * Display replace data value.
*/ */
public void replaceData() public void replaceData() {
{
snipeData.sendMessage(ChatColor.DARK_GRAY + "Replace Data Variable: " + ChatColor.DARK_RED + snipeData.getReplaceData()); snipeData.sendMessage(ChatColor.DARK_GRAY + "Replace Data Variable: " + ChatColor.DARK_RED + snipeData.getReplaceData());
} }
/** /**
* Display brush size. * Display brush size.
*/ */
public void size() public void size() {
{
snipeData.sendMessage(ChatColor.GREEN + "Brush Size: " + ChatColor.DARK_RED + snipeData.getBrushSize()); snipeData.sendMessage(ChatColor.GREEN + "Brush Size: " + ChatColor.DARK_RED + snipeData.getBrushSize());
if (snipeData.getBrushSize() >= BRUSH_SIZE_WARNING_THRESHOLD) if (snipeData.getBrushSize() >= BRUSH_SIZE_WARNING_THRESHOLD) {
{
snipeData.sendMessage(ChatColor.RED + "WARNING: Large brush size selected!"); snipeData.sendMessage(ChatColor.RED + "WARNING: Large brush size selected!");
} }
} }
@ -117,24 +102,21 @@ public class Message
/** /**
* Display toggle lightning message. * Display toggle lightning message.
*/ */
public void toggleLightning() public void toggleLightning() {
{
snipeData.sendMessage(ChatColor.GOLD + "Lightning mode has been toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isLightningEnabled()) ? "on" : "off")); snipeData.sendMessage(ChatColor.GOLD + "Lightning mode has been toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isLightningEnabled()) ? "on" : "off"));
} }
/** /**
* Display toggle printout message. * Display toggle printout message.
*/ */
public final void togglePrintout() public final void togglePrintout() {
{
snipeData.sendMessage(ChatColor.GOLD + "Brush info printout mode has been toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isLightningEnabled()) ? "on" : "off")); snipeData.sendMessage(ChatColor.GOLD + "Brush info printout mode has been toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isLightningEnabled()) ? "on" : "off"));
} }
/** /**
* Display toggle range message. * Display toggle range message.
*/ */
public void toggleRange() public void toggleRange() {
{
snipeData.sendMessage(ChatColor.GOLD + "Distance Restriction toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isRanged()) ? "on" : "off") + ChatColor.GOLD + ". Range is " + ChatColor.LIGHT_PURPLE + (double) snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).getRange()); snipeData.sendMessage(ChatColor.GOLD + "Distance Restriction toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isRanged()) ? "on" : "off") + ChatColor.GOLD + ". Range is " + ChatColor.LIGHT_PURPLE + (double) snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).getRange());
} }
@ -142,22 +124,17 @@ public class Message
* Display voxel type. * Display voxel type.
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void voxel() public void voxel() {
{
snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + BlockTypes.get(snipeData.getVoxelId())); snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + BlockTypes.get(snipeData.getVoxelId()));
} }
/** /**
* Display voxel list. * Display voxel list.
*/ */
public void voxelList() public void voxelList() {
{ if (snipeData.getVoxelList().isEmpty()) {
if (snipeData.getVoxelList().isEmpty())
{
snipeData.sendMessage(ChatColor.DARK_GREEN + "No blocks selected!"); snipeData.sendMessage(ChatColor.DARK_GREEN + "No blocks selected!");
} } else {
else
{
String returnValueBuilder = ChatColor.DARK_GREEN + "Block Types Selected: " + ChatColor.AQUA String returnValueBuilder = ChatColor.DARK_GREEN + "Block Types Selected: " + ChatColor.AQUA
+ snipeData.getVoxelList(); + snipeData.getVoxelList();
snipeData.sendMessage(returnValueBuilder); snipeData.sendMessage(returnValueBuilder);

Datei anzeigen

@ -4,96 +4,72 @@ import org.bukkit.Art;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Painting; import org.bukkit.entity.Painting;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Set;
/** /**
* Painting state change handler. * Painting state change handler.
* *
* @author Piotr * @author Piotr
*/ */
public final class PaintingWrapper public final class PaintingWrapper {
{
private PaintingWrapper() private PaintingWrapper() {
{
} }
/** /**
* The paint method used to scroll or set a painting to a specific type. * The paint method used to scroll or set a painting to a specific type.
* *
* @param p * @param p The player executing the method
* The player executing the method * @param auto Scroll automatically? If false will use 'choice' to try and set the painting
* @param auto * @param back Scroll in reverse?
* Scroll automatically? If false will use 'choice' to try and set the painting * @param choice Chosen index to set the painting to
* @param back
* Scroll in reverse?
* @param choice
* Chosen index to set the painting to
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void paint(final Player p, final boolean auto, final boolean back, final int choice) public static void paint(final Player p, final boolean auto, final boolean back, final int choice) {
{
Location targetLocation = p.getTargetBlock(null, 4).getLocation(); Location targetLocation = p.getTargetBlock(null, 4).getLocation();
Chunk paintingChunk = p.getTargetBlock(null, 4).getLocation().getChunk(); Chunk paintingChunk = p.getTargetBlock(null, 4).getLocation().getChunk();
Double bestDistanceMatch = 50D; Double bestDistanceMatch = 50D;
Painting bestMatch = null; Painting bestMatch = null;
for (Entity entity : paintingChunk.getEntities()) for (Entity entity : paintingChunk.getEntities()) {
{ if (entity.getType() == EntityType.PAINTING) {
if (entity.getType() == EntityType.PAINTING)
{
Double distance = targetLocation.distanceSquared(entity.getLocation()); Double distance = targetLocation.distanceSquared(entity.getLocation());
if (distance <= 4 && distance < bestDistanceMatch) if (distance <= 4 && distance < bestDistanceMatch) {
{
bestDistanceMatch = distance; bestDistanceMatch = distance;
bestMatch = (Painting) entity; bestMatch = (Painting) entity;
} }
} }
} }
if (bestMatch != null) if (bestMatch != null) {
{ if (auto) {
if (auto) try {
{
try
{
final int i = bestMatch.getArt().getId() + (back ? -1 : 1); final int i = bestMatch.getArt().getId() + (back ? -1 : 1);
Art art = Art.getById(i); Art art = Art.getById(i);
if (art == null) if (art == null) {
{
p.sendMessage(ChatColor.RED + "This is the final painting, try scrolling to the other direction."); p.sendMessage(ChatColor.RED + "This is the final painting, try scrolling to the other direction.");
return; return;
} }
bestMatch.setArt(art); bestMatch.setArt(art);
p.sendMessage(ChatColor.GREEN + "Painting set to ID: " + (i)); p.sendMessage(ChatColor.GREEN + "Painting set to ID: " + (i));
} } catch (final Exception e) {
catch (final Exception e)
{
p.sendMessage(ChatColor.RED + "Oops. Something went wrong."); p.sendMessage(ChatColor.RED + "Oops. Something went wrong.");
} }
} } else {
else try {
{
try
{
Art art = Art.getById(choice); Art art = Art.getById(choice);
bestMatch.setArt(art); bestMatch.setArt(art);
p.sendMessage(ChatColor.GREEN + "Painting set to ID: " + choice); p.sendMessage(ChatColor.GREEN + "Painting set to ID: " + choice);
} } catch (final Exception exception) {
catch (final Exception exception)
{
p.sendMessage(ChatColor.RED + "Your input was invalid somewhere."); p.sendMessage(ChatColor.RED + "Your input was invalid somewhere.");
} }
} }

Datei anzeigen

@ -30,8 +30,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class RangeBlockHelper { public class RangeBlockHelper {

Datei anzeigen

@ -1,9 +1,8 @@
package com.thevoxelbox.voxelsniper; package com.thevoxelbox.voxelsniper;
/** /**
* *
*/ */
public enum SnipeAction public enum SnipeAction {
{
ARROW, GUNPOWDER ARROW, GUNPOWDER
} }

Datei anzeigen

@ -44,25 +44,16 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.*; import com.google.common.collect.*;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.MaskingExtent; import com.sk89q.worldedit.extent.MaskingExtent;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.brush.IBrush; import com.thevoxelbox.voxelsniper.brush.IBrush;
import com.thevoxelbox.voxelsniper.brush.SnipeBrush; import com.thevoxelbox.voxelsniper.brush.SnipeBrush;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import com.thevoxelbox.voxelsniper.brush.perform.Performer; import com.thevoxelbox.voxelsniper.brush.perform.Performer;
import com.thevoxelbox.voxelsniper.event.SniperMaterialChangedEvent;
import com.thevoxelbox.voxelsniper.event.SniperReplaceMaterialChangedEvent;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -72,9 +63,13 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.material.MaterialData;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class Sniper { public class Sniper {
private VoxelSniper plugin; private VoxelSniper plugin;
private final UUID player; private final UUID player;

Datei anzeigen

@ -9,20 +9,16 @@ import java.util.UUID;
/** /**
* *
*/ */
public class SniperManager public class SniperManager {
{
private Map<UUID, Sniper> sniperInstances = Maps.newHashMap(); private Map<UUID, Sniper> sniperInstances = Maps.newHashMap();
private VoxelSniper plugin; private VoxelSniper plugin;
public SniperManager(VoxelSniper plugin) public SniperManager(VoxelSniper plugin) {
{
this.plugin = plugin; this.plugin = plugin;
} }
public Sniper getSniperForPlayer(Player player) public Sniper getSniperForPlayer(Player player) {
{ if (sniperInstances.get(player.getUniqueId()) == null) {
if (sniperInstances.get(player.getUniqueId()) == null)
{
sniperInstances.put(player.getUniqueId(), new Sniper(plugin, player)); sniperInstances.put(player.getUniqueId(), new Sniper(plugin, player));
} }
return sniperInstances.get(player.getUniqueId()); return sniperInstances.get(player.getUniqueId());

Datei anzeigen

@ -1,34 +1,19 @@
package com.thevoxelbox.voxelsniper; package com.thevoxelbox.voxelsniper;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.BukkitCommand; import com.boydti.fawe.bukkit.BukkitCommand;
import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.util.Jars;
import com.boydti.fawe.util.MainUtil;
import com.google.common.base.Preconditions;
import com.thevoxelbox.voxelsniper.brush.*; import com.thevoxelbox.voxelsniper.brush.*;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import com.thevoxelbox.voxelsniper.command.VoxelVoxelCommand;
import com.thevoxelbox.voxelsniper.event.SniperBrushChangedEvent;
import com.thevoxelbox.voxelsniper.event.SniperMaterialChangedEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
/** /**
* Bukkit extension point. * Bukkit extension point.
*/ */
public class VoxelSniper extends JavaPlugin public class VoxelSniper extends JavaPlugin {
{
private static VoxelSniper instance; private static VoxelSniper instance;
private SniperManager sniperManager = new SniperManager(this); private SniperManager sniperManager = new SniperManager(this);
private final VoxelSniperListener voxelSniperListener = new VoxelSniperListener(this); private final VoxelSniperListener voxelSniperListener = new VoxelSniperListener(this);
@ -39,8 +24,7 @@ public class VoxelSniper extends JavaPlugin
* *
* @return Brush Manager for current instance. * @return Brush Manager for current instance.
*/ */
public Brushes getBrushManager() public Brushes getBrushManager() {
{
return brushManager; return brushManager;
} }
@ -49,8 +33,7 @@ public class VoxelSniper extends JavaPlugin
/** /**
* @return {@link VoxelSniper} * @return {@link VoxelSniper}
*/ */
public static VoxelSniper getInstance() public static VoxelSniper getInstance() {
{
return VoxelSniper.instance; return VoxelSniper.instance;
} }
@ -59,8 +42,7 @@ public class VoxelSniper extends JavaPlugin
* *
* @return {@link VoxelSniperConfiguration} object for accessing global VoxelSniper options. * @return {@link VoxelSniperConfiguration} object for accessing global VoxelSniper options.
*/ */
public VoxelSniperConfiguration getVoxelSniperConfiguration() public VoxelSniperConfiguration getVoxelSniperConfiguration() {
{
return voxelSniperConfiguration; return voxelSniperConfiguration;
} }
@ -69,20 +51,16 @@ public class VoxelSniper extends JavaPlugin
* *
* @return SniperManager * @return SniperManager
*/ */
public SniperManager getSniperManager() public SniperManager getSniperManager() {
{
return sniperManager; return sniperManager;
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
{ if (sender instanceof Player) {
if (sender instanceof Player)
{
String[] arguments = args; String[] arguments = args;
if (arguments == null) if (arguments == null) {
{
arguments = new String[0]; arguments = new String[0];
} }
@ -94,8 +72,7 @@ public class VoxelSniper extends JavaPlugin
} }
@Override @Override
public void onEnable() public void onEnable() {
{
VoxelSniper.instance = this; VoxelSniper.instance = this;
registerBrushes(); registerBrushes();
@ -134,14 +111,14 @@ public class VoxelSniper extends JavaPlugin
} }
}); });
} catch (Throwable ignore) {} } catch (Throwable ignore) {
}
} }
/** /**
* Registers all brushes. * Registers all brushes.
*/ */
public void registerBrushes() public void registerBrushes() {
{
brushManager.registerSniperBrush(BallBrush.class, "b", "ball"); brushManager.registerSniperBrush(BallBrush.class, "b", "ball");
brushManager.registerSniperBrush(BiomeBrush.class, "bio", "biome"); brushManager.registerSniperBrush(BiomeBrush.class, "bio", "biome");
brushManager.registerSniperBrush(BlendBallBrush.class, "bb", "blendball"); brushManager.registerSniperBrush(BlendBallBrush.class, "bb", "blendball");

Datei anzeigen

@ -8,8 +8,7 @@ import java.util.List;
/** /**
* Configuration storage defining global configurations for VoxelSniper. * Configuration storage defining global configurations for VoxelSniper.
*/ */
public class VoxelSniperConfiguration public class VoxelSniperConfiguration {
{
public static final String CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE = "litesniper-max-brush-size"; public static final String CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE = "litesniper-max-brush-size";
public static final String CONFIG_IDENTIFIER_UNDO_CACHE_SIZE = "undo-cache-size"; public static final String CONFIG_IDENTIFIER_UNDO_CACHE_SIZE = "undo-cache-size";
public static final String CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS = "litesniper-restricted-items"; public static final String CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS = "litesniper-restricted-items";
@ -22,8 +21,7 @@ public class VoxelSniperConfiguration
/** /**
* @param configuration Configuration that is going to be used. * @param configuration Configuration that is going to be used.
*/ */
public VoxelSniperConfiguration(FileConfiguration configuration) public VoxelSniperConfiguration(FileConfiguration configuration) {
{
this.configuration = configuration; this.configuration = configuration;
} }
@ -32,8 +30,7 @@ public class VoxelSniperConfiguration
* *
* @return the maximum amount of snipes stored in the undo cache of snipers * @return the maximum amount of snipes stored in the undo cache of snipers
*/ */
public int getUndoCacheSize() public int getUndoCacheSize() {
{
return configuration.getInt(CONFIG_IDENTIFIER_UNDO_CACHE_SIZE, DEFAULT_UNDO_CACHE_SIZE); return configuration.getInt(CONFIG_IDENTIFIER_UNDO_CACHE_SIZE, DEFAULT_UNDO_CACHE_SIZE);
} }
@ -42,8 +39,7 @@ public class VoxelSniperConfiguration
* *
* @param size size of undo cache * @param size size of undo cache
*/ */
public void setUndoCacheSize(int size) public void setUndoCacheSize(int size) {
{
configuration.set(CONFIG_IDENTIFIER_UNDO_CACHE_SIZE, size); configuration.set(CONFIG_IDENTIFIER_UNDO_CACHE_SIZE, size);
} }
@ -52,8 +48,7 @@ public class VoxelSniperConfiguration
* *
* @return maximum size * @return maximum size
*/ */
public int getLiteSniperMaxBrushSize() public int getLiteSniperMaxBrushSize() {
{
return configuration.getInt(CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE, DEFAULT_LITESNIPER_MAX_BRUSH_SIZE); return configuration.getInt(CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE, DEFAULT_LITESNIPER_MAX_BRUSH_SIZE);
} }
@ -62,8 +57,7 @@ public class VoxelSniperConfiguration
* *
* @param size maximum size * @param size maximum size
*/ */
public void setLiteSniperMaxBrushSize(int size) public void setLiteSniperMaxBrushSize(int size) {
{
configuration.set(CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE, size); configuration.set(CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE, size);
} }
@ -72,8 +66,7 @@ public class VoxelSniperConfiguration
* *
* @return List of restricted Litesniper Items * @return List of restricted Litesniper Items
*/ */
public List<Integer> getLiteSniperRestrictedItems() public List<Integer> getLiteSniperRestrictedItems() {
{
return configuration.getIntegerList(CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS); return configuration.getIntegerList(CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS);
} }
@ -82,8 +75,7 @@ public class VoxelSniperConfiguration
* *
* @param restrictedItems List of restricted Litesniper Items * @param restrictedItems List of restricted Litesniper Items
*/ */
public void setLitesniperRestrictedItems(List<Integer> restrictedItems) public void setLitesniperRestrictedItems(List<Integer> restrictedItems) {
{
Preconditions.checkNotNull(restrictedItems, "Restricted items must be a list."); Preconditions.checkNotNull(restrictedItems, "Restricted items must be a list.");
configuration.set(CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS, restrictedItems); configuration.set(CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS, restrictedItems);
} }
@ -93,8 +85,7 @@ public class VoxelSniperConfiguration
* *
* @return true if message on login is enabled, false otherwise. * @return true if message on login is enabled, false otherwise.
*/ */
public boolean isMessageOnLoginEnabled() public boolean isMessageOnLoginEnabled() {
{
return configuration.getBoolean(CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED, DEFAULT_MESSAGE_ON_LOGIN_ENABLED); return configuration.getBoolean(CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED, DEFAULT_MESSAGE_ON_LOGIN_ENABLED);
} }
@ -103,8 +94,7 @@ public class VoxelSniperConfiguration
* *
* @param enabled Message on Login enabled * @param enabled Message on Login enabled
*/ */
public void setMessageOnLoginEnabled(boolean enabled) public void setMessageOnLoginEnabled(boolean enabled) {
{
configuration.set(CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED, enabled); configuration.set(CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED, enabled);
} }
} }

Datei anzeigen

@ -16,13 +16,11 @@ import org.bukkit.event.player.PlayerJoinEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
/** /**
* @author Voxel * @author Voxel
*/ */
public class VoxelSniperListener implements Listener public class VoxelSniperListener implements Listener {
{
private static final String SNIPER_PERMISSION = "voxelsniper.sniper"; private static final String SNIPER_PERMISSION = "voxelsniper.sniper";
private final VoxelSniper plugin; private final VoxelSniper plugin;
@ -31,8 +29,7 @@ public class VoxelSniperListener implements Listener
/** /**
* @param plugin * @param plugin
*/ */
public VoxelSniperListener(final VoxelSniper plugin) public VoxelSniperListener(final VoxelSniper plugin) {
{
this.plugin = plugin; this.plugin = plugin;
addCommand(new VoxelBrushCommand(plugin)); addCommand(new VoxelBrushCommand(plugin));
addCommand(new VoxelBrushToolCommand(plugin)); addCommand(new VoxelBrushToolCommand(plugin));
@ -53,8 +50,7 @@ public class VoxelSniperListener implements Listener
addCommand(new VoxelVoxelCommand(plugin)); addCommand(new VoxelVoxelCommand(plugin));
} }
private void addCommand(final VoxelCommand command) private void addCommand(final VoxelCommand command) {
{
this.commands.put(command.getIdentifier().toLowerCase(), command); this.commands.put(command.getIdentifier().toLowerCase(), command);
} }
@ -64,16 +60,13 @@ public class VoxelSniperListener implements Listener
* @param command * @param command
* @return boolean Success. * @return boolean Success.
*/ */
public boolean onCommand(final Player player, final String[] split, final String command) public boolean onCommand(final Player player, final String[] split, final String command) {
{
VoxelCommand found = this.commands.get(command.toLowerCase()); VoxelCommand found = this.commands.get(command.toLowerCase());
if (found == null) if (found == null) {
{
return false; return false;
} }
if (!hasPermission(found, player)) if (!hasPermission(found, player)) {
{
player.sendMessage(ChatColor.RED + "Insufficient Permissions."); player.sendMessage(ChatColor.RED + "Insufficient Permissions.");
return true; return true;
} }
@ -111,20 +104,14 @@ public class VoxelSniperListener implements Listener
return true; return true;
} }
private boolean hasPermission(final VoxelCommand command, final Player player) private boolean hasPermission(final VoxelCommand command, final Player player) {
{ if (command == null || player == null) {
if (command == null || player == null)
{
// Just a usual check for nulls // Just a usual check for nulls
return false; return false;
} } else if (command.getPermission() == null || command.getPermission().isEmpty()) {
else if (command.getPermission() == null || command.getPermission().isEmpty())
{
// This is for commands that do not require a permission node to be executed // This is for commands that do not require a permission node to be executed
return true; return true;
} } else {
else
{
// Should utilize Vault for permission checks if available // Should utilize Vault for permission checks if available
return player.hasPermission(command.getPermission()); return player.hasPermission(command.getPermission());
} }
@ -134,25 +121,19 @@ public class VoxelSniperListener implements Listener
* @param event * @param event
*/ */
@EventHandler(ignoreCancelled = false) @EventHandler(ignoreCancelled = false)
public final void onPlayerInteract(final PlayerInteractEvent event) public final void onPlayerInteract(final PlayerInteractEvent event) {
{
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!player.hasPermission(SNIPER_PERMISSION)) if (!player.hasPermission(SNIPER_PERMISSION)) {
{
return; return;
} }
try try {
{
Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player);
if (sniper.isEnabled() && sniper.snipe(event.getAction(), event.getMaterial(), event.getClickedBlock(), event.getBlockFace())) if (sniper.isEnabled() && sniper.snipe(event.getAction(), event.getMaterial(), event.getClickedBlock(), event.getBlockFace())) {
{
event.setCancelled(true); event.setCancelled(true);
} }
} } catch (final Throwable ignored) {
catch (final Throwable ignored)
{
ignored.printStackTrace(); ignored.printStackTrace();
} }
} }
@ -161,13 +142,11 @@ public class VoxelSniperListener implements Listener
* @param event * @param event
*/ */
@EventHandler @EventHandler
public final void onPlayerJoin(final PlayerJoinEvent event) public final void onPlayerJoin(final PlayerJoinEvent event) {
{
Player player = event.getPlayer(); Player player = event.getPlayer();
Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player);
if (player.hasPermission(SNIPER_PERMISSION) && plugin.getVoxelSniperConfiguration().isMessageOnLoginEnabled()) if (player.hasPermission(SNIPER_PERMISSION) && plugin.getVoxelSniperConfiguration().isMessageOnLoginEnabled()) {
{
sniper.displayInfo(); sniper.displayInfo();
} }
} }

Datei anzeigen

@ -4,9 +4,7 @@ import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
/** /**
* A brush that creates a solid ball. * A brush that creates a solid ball.
@ -14,8 +12,7 @@ import org.bukkit.block.Block;
* *
* @author Piotr * @author Piotr
*/ */
public class BallBrush extends PerformBrush public class BallBrush extends PerformBrush {
{
public static final double TRUE_CIRCLE_ON_VALUE = 0.5; public static final double TRUE_CIRCLE_ON_VALUE = 0.5;
public static final int TRUE_CIRCLE_OFF_VALUE = 0; public static final int TRUE_CIRCLE_OFF_VALUE = 0;
private double trueCircle = 0; private double trueCircle = 0;
@ -23,13 +20,11 @@ public class BallBrush extends PerformBrush
/** /**
* *
*/ */
public BallBrush() public BallBrush() {
{
this.setName("Ball"); this.setName("Ball");
} }
private void ball(final SnipeData v, AsyncBlock targetBlock) private void ball(final SnipeData v, AsyncBlock targetBlock) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
@ -38,8 +33,7 @@ public class BallBrush extends PerformBrush
int blockPositionZ = targetBlock.getZ(); int blockPositionZ = targetBlock.getZ();
this.current.perform(targetBlock); this.current.perform(targetBlock);
for (int z = 1; z <= brushSize; z++) for (int z = 1; z <= brushSize; z++) {
{
final double zSquared = Math.pow(z, 2); final double zSquared = Math.pow(z, 2);
this.current.perform(this.clampY(blockPositionX + z, blockPositionY, blockPositionZ)); this.current.perform(this.clampY(blockPositionX + z, blockPositionY, blockPositionZ));
@ -49,12 +43,10 @@ public class BallBrush extends PerformBrush
this.current.perform(this.clampY(blockPositionX, blockPositionY, blockPositionZ + z)); this.current.perform(this.clampY(blockPositionX, blockPositionY, blockPositionZ + z));
this.current.perform(this.clampY(blockPositionX, blockPositionY, blockPositionZ - z)); this.current.perform(this.clampY(blockPositionX, blockPositionY, blockPositionZ - z));
for (int x = 1; x <= brushSize; x++) for (int x = 1; x <= brushSize; x++) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
if (zSquared + xSquared <= brushSizeSquared) if (zSquared + xSquared <= brushSizeSquared) {
{
this.current.perform(this.clampY(blockPositionX + z, blockPositionY, blockPositionZ + x)); this.current.perform(this.clampY(blockPositionX + z, blockPositionY, blockPositionZ + x));
this.current.perform(this.clampY(blockPositionX + z, blockPositionY, blockPositionZ - x)); this.current.perform(this.clampY(blockPositionX + z, blockPositionY, blockPositionZ - x));
this.current.perform(this.clampY(blockPositionX - z, blockPositionY, blockPositionZ + x)); this.current.perform(this.clampY(blockPositionX - z, blockPositionY, blockPositionZ + x));
@ -69,10 +61,8 @@ public class BallBrush extends PerformBrush
this.current.perform(this.clampY(blockPositionX, blockPositionY - z, blockPositionZ - x)); this.current.perform(this.clampY(blockPositionX, blockPositionY - z, blockPositionZ - x));
} }
for (int y = 1; y <= brushSize; y++) for (int y = 1; y <= brushSize; y++) {
{ if ((xSquared + Math.pow(y, 2) + zSquared) <= brushSizeSquared) {
if ((xSquared + Math.pow(y, 2) + zSquared) <= brushSizeSquared)
{
this.current.perform(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ + z)); this.current.perform(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ + z));
this.current.perform(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ - z)); this.current.perform(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ - z));
this.current.perform(this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ + z)); this.current.perform(this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ + z));
@ -90,57 +80,44 @@ public class BallBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.ball(v, this.getTargetBlock()); this.ball(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.ball(v, this.getLastBlock()); this.ball(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Ball Brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Ball Brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b b true -- will use a true sphere algorithm instead of the skinnier version with classic sniper nubs. /b b false will switch back. (false is default)"); v.sendMessage(ChatColor.AQUA + "/b b true -- will use a true sphere algorithm instead of the skinnier version with classic sniper nubs. /b b false will switch back. (false is default)");
return; return;
} } else if (parameter.startsWith("true")) {
else if (parameter.startsWith("true"))
{
this.trueCircle = TRUE_CIRCLE_ON_VALUE; this.trueCircle = TRUE_CIRCLE_ON_VALUE;
v.sendMessage(ChatColor.AQUA + "True circle mode ON."); v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
} } else if (parameter.startsWith("false")) {
else if (parameter.startsWith("false"))
{
this.trueCircle = TRUE_CIRCLE_OFF_VALUE; this.trueCircle = TRUE_CIRCLE_OFF_VALUE;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.ball"; return "voxelsniper.brush.ball";
} }
} }

Datei anzeigen

@ -9,31 +9,25 @@ import org.bukkit.block.Block;
/** /**
* *
*/ */
public class BiomeBrush extends Brush public class BiomeBrush extends Brush {
{
private Biome selectedBiome = Biome.PLAINS; private Biome selectedBiome = Biome.PLAINS;
/** /**
* *
*/ */
public BiomeBrush() public BiomeBrush() {
{
this.setName("Biome (/b biome [Biome Name])"); this.setName("Biome (/b biome [Biome Name])");
} }
private void biome(final SnipeData v) private void biome(final SnipeData v) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize, 2); final double brushSizeSquared = Math.pow(brushSize, 2);
for (int x = -brushSize; x <= brushSize; x++) for (int x = -brushSize; x <= brushSize; x++) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int z = -brushSize; z <= brushSize; z++) for (int z = -brushSize; z <= brushSize; z++) {
{ if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared) {
if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared)
{
this.getWorld().setBiome(this.getTargetBlock().getX() + x, this.getTargetBlock().getZ() + z, this.selectedBiome); this.getWorld().setBiome(this.getTargetBlock().getX() + x, this.getTargetBlock().getZ() + z, this.selectedBiome);
} }
} }
@ -47,70 +41,56 @@ public class BiomeBrush extends Brush
final int highChunkX = (block1.getX() >= block2.getX()) ? block1.getChunk().getX() : block2.getChunk().getX(); final int highChunkX = (block1.getX() >= block2.getX()) ? block1.getChunk().getX() : block2.getChunk().getX();
final int highChunkZ = (block1.getZ() >= block2.getZ()) ? block1.getChunk().getZ() : block2.getChunk().getZ(); final int highChunkZ = (block1.getZ() >= block2.getZ()) ? block1.getChunk().getZ() : block2.getChunk().getZ();
for (int x = lowChunkX; x <= highChunkX; x++) for (int x = lowChunkX; x <= highChunkX; x++) {
{ for (int z = lowChunkZ; z <= highChunkZ; z++) {
for (int z = lowChunkZ; z <= highChunkZ; z++)
{
this.getWorld().refreshChunk(x, z); this.getWorld().refreshChunk(x, z);
} }
} }
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.biome(v); this.biome(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.biome(v); this.biome(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.custom(ChatColor.GOLD + "Currently selected biome type: " + ChatColor.DARK_GREEN + this.selectedBiome.name()); vm.custom(ChatColor.GOLD + "Currently selected biome type: " + ChatColor.DARK_GREEN + this.selectedBiome.name());
} }
@Override @Override
public final void parameters(final String[] args, final SnipeData v) public final void parameters(final String[] args, final SnipeData v) {
{ if (args[1].equalsIgnoreCase("info")) {
if (args[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Biome Brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Biome Brush Parameters:");
StringBuilder availableBiomes = new StringBuilder(); StringBuilder availableBiomes = new StringBuilder();
for (final Biome biome : Biome.values()) for (final Biome biome : Biome.values()) {
{ if (availableBiomes.length() == 0) {
if (availableBiomes.length() == 0)
{
availableBiomes = new StringBuilder(ChatColor.DARK_GREEN + biome.name()); availableBiomes = new StringBuilder(ChatColor.DARK_GREEN + biome.name());
continue; continue;
} }
availableBiomes.append(ChatColor.RED + ", " + ChatColor.DARK_GREEN) availableBiomes.append(ChatColor.RED + ", " + ChatColor.DARK_GREEN)
.append(biome.name()); .append(biome.name());
} }
v.sendMessage(ChatColor.DARK_BLUE + "Available biomes: " + availableBiomes); v.sendMessage(ChatColor.DARK_BLUE + "Available biomes: " + availableBiomes);
} } else {
else
{
// allows biome names with spaces in their name // allows biome names with spaces in their name
StringBuilder biomeName = new StringBuilder(args[1]); StringBuilder biomeName = new StringBuilder(args[1]);
for (int i = 2; i < args.length; i++) for (int i = 2; i < args.length; i++) {
{
biomeName.append(" ").append(args[i]); biomeName.append(" ").append(args[i]);
} }
for (final Biome biome : Biome.values()) for (final Biome biome : Biome.values()) {
{ if (biome.name().equalsIgnoreCase(biomeName.toString())) {
if (biome.name().equalsIgnoreCase(biomeName.toString()))
{
this.selectedBiome = biome; this.selectedBiome = biome;
break; break;
} }
@ -120,8 +100,7 @@ public class BiomeBrush extends Brush
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.biome"; return "voxelsniper.brush.biome";
} }
} }

Datei anzeigen

@ -4,27 +4,22 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes * http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes
*/ */
public class BlendBallBrush extends BlendBrushBase public class BlendBallBrush extends BlendBrushBase {
{
/** /**
* *
*/ */
public BlendBallBrush() public BlendBallBrush() {
{
this.setName("Blend Ball"); this.setName("Blend Ball");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected final void blend(final SnipeData v) protected final void blend(final SnipeData v) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final int brushSizeDoubled = 2 * brushSize; final int brushSizeDoubled = 2 * brushSize;
// Array that holds the original materials plus a buffer // Array that holds the original materials plus a buffer
@ -33,47 +28,35 @@ public class BlendBallBrush extends BlendBrushBase
final int[][][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; final int[][][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1];
// Log current materials into oldmats // Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++) for (int x = 0; x <= 2 * (brushSize + 1); x++) {
{ for (int y = 0; y <= 2 * (brushSize + 1); y++) {
for (int y = 0; y <= 2 * (brushSize + 1); y++) for (int z = 0; z <= 2 * (brushSize + 1); z++) {
{
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
oldMaterials[x][y][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY() - brushSize - 1 + y, this.getTargetBlock().getZ() - brushSize - 1 + z); oldMaterials[x][y][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY() - brushSize - 1 + y, this.getTargetBlock().getZ() - brushSize - 1 + z);
} }
} }
} }
// Log current materials into newmats // Log current materials into newmats
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{ for (int y = 0; y <= brushSizeDoubled; y++) {
for (int y = 0; y <= brushSizeDoubled; y++)
{
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0, System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
brushSizeDoubled + 1); brushSizeDoubled + 1);
} }
} }
// Blend materials // Blend materials
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{ for (int y = 0; y <= brushSizeDoubled; y++) {
for (int y = 0; y <= brushSizeDoubled; y++) for (int z = 0; z <= brushSizeDoubled; z++) {
{
for (int z = 0; z <= brushSizeDoubled; z++)
{
final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block
int modeMatCount = 0; int modeMatCount = 0;
int modeMatId = 0; int modeMatId = 0;
boolean tiecheck = true; boolean tiecheck = true;
for (int m = -1; m <= 1; m++) for (int m = -1; m <= 1; m++) {
{ for (int n = -1; n <= 1; n++) {
for (int n = -1; n <= 1; n++) for (int o = -1; o <= 1; o++) {
{ if (!(m == 0 && n == 0 && o == 0)) {
for (int o = -1; o <= 1; o++)
{
if (!(m == 0 && n == 0 && o == 0))
{
materialFrequency[oldMaterials[x + 1 + m][y + 1 + n][z + 1 + o]]++; materialFrequency[oldMaterials[x + 1 + m][y + 1 + n][z + 1 + o]]++;
} }
} }
@ -81,28 +64,23 @@ public class BlendBallBrush extends BlendBrushBase
} }
// Find most common neighboring material. // Find most common neighboring material.
for (BlockType type : BlockTypes.values) for (BlockType type : BlockTypes.values) {
{
int i = type.getInternalId(); int i = type.getInternalId();
if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) {
{
modeMatCount = materialFrequency[i]; modeMatCount = materialFrequency[i];
modeMatId = i; modeMatId = i;
} }
} }
// Make sure there'world not a tie for most common // Make sure there'world not a tie for most common
for (int i = 0; i < modeMatId; i++) for (int i = 0; i < modeMatId; i++) {
{
BlockType type = BlockTypes.get(i); BlockType type = BlockTypes.get(i);
if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) {
{
tiecheck = false; tiecheck = false;
} }
} }
// Record most common neighbor material for this block // Record most common neighbor material for this block
if (tiecheck) if (tiecheck) {
{
newMaterials[x][y][z] = modeMatId; newMaterials[x][y][z] = modeMatId;
} }
} }
@ -113,22 +91,16 @@ public class BlendBallBrush extends BlendBrushBase
final double rSquared = Math.pow(brushSize + 1, 2); final double rSquared = Math.pow(brushSize + 1, 2);
// Make the changes // Make the changes
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{
final double xSquared = Math.pow(x - brushSize - 1, 2); final double xSquared = Math.pow(x - brushSize - 1, 2);
for (int y = 0; y <= brushSizeDoubled; y++) for (int y = 0; y <= brushSizeDoubled; y++) {
{
final double ySquared = Math.pow(y - brushSize - 1, 2); final double ySquared = Math.pow(y - brushSize - 1, 2);
for (int z = brushSizeDoubled; z >= 0; z--) for (int z = brushSizeDoubled; z >= 0; z--) {
{ if (xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared) {
if (xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared) if (!(this.excludeAir && BlockTypes.get(newMaterials[x][y][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][y][z] == BlockTypes.WATER.getInternalId()))) {
{ if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][y][z]) {
if (!(this.excludeAir && BlockTypes.get(newMaterials[x][y][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][y][z] == BlockTypes.WATER.getInternalId())))
{
if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][y][z])
{
undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z)); undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z));
} }
this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, newMaterials[x][y][z]); this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, newMaterials[x][y][z]);
@ -141,10 +113,8 @@ public class BlendBallBrush extends BlendBrushBase
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Blend Ball Parameters:"); v.sendMessage(ChatColor.GOLD + "Blend Ball Parameters:");
v.sendMessage(ChatColor.AQUA + "/b bb water -- toggle include or exclude (default: exclude) water"); v.sendMessage(ChatColor.AQUA + "/b bb water -- toggle include or exclude (default: exclude) water");
return; return;
@ -154,8 +124,7 @@ public class BlendBallBrush extends BlendBrushBase
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.blendball"; return "voxelsniper.brush.blendball";
} }
} }

Datei anzeigen

@ -1,20 +1,14 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import com.bekvon.bukkit.residence.commands.material;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
/** /**
* @author Monofraps * @author Monofraps
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public abstract class BlendBrushBase extends Brush public abstract class BlendBrushBase extends Brush {
{
protected boolean excludeAir = true; protected boolean excludeAir = true;
protected boolean excludeWater = true; protected boolean excludeWater = true;
@ -24,22 +18,19 @@ public abstract class BlendBrushBase extends Brush
protected abstract void blend(final SnipeData v); protected abstract void blend(final SnipeData v);
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.excludeAir = false; this.excludeAir = false;
this.blend(v); this.blend(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.excludeAir = true; this.excludeAir = true;
this.blend(v); this.blend(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.voxel(); vm.voxel();
@ -47,12 +38,9 @@ public abstract class BlendBrushBase extends Brush
} }
@Override @Override
public void parameters(final String[] par, final SnipeData v) public void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; ++i) {
for (int i = 1; i < par.length; ++i) if (par[i].equalsIgnoreCase("water")) {
{
if (par[i].equalsIgnoreCase("water"))
{
this.excludeWater = !this.excludeWater; this.excludeWater = !this.excludeWater;
v.sendMessage(ChatColor.AQUA + "Water Mode: " + (this.excludeWater ? "exclude" : "include")); v.sendMessage(ChatColor.AQUA + "Water Mode: " + (this.excludeWater ? "exclude" : "include"));
} }
@ -62,32 +50,28 @@ public abstract class BlendBrushBase extends Brush
/** /**
* @return * @return
*/ */
protected final boolean isExcludeAir() protected final boolean isExcludeAir() {
{
return excludeAir; return excludeAir;
} }
/** /**
* @param excludeAir * @param excludeAir
*/ */
protected final void setExcludeAir(boolean excludeAir) protected final void setExcludeAir(boolean excludeAir) {
{
this.excludeAir = excludeAir; this.excludeAir = excludeAir;
} }
/** /**
* @return * @return
*/ */
protected final boolean isExcludeWater() protected final boolean isExcludeWater() {
{
return excludeWater; return excludeWater;
} }
/** /**
* @param excludeWater * @param excludeWater
*/ */
protected final void setExcludeWater(boolean excludeWater) protected final void setExcludeWater(boolean excludeWater) {
{
this.excludeWater = excludeWater; this.excludeWater = excludeWater;
} }
} }

Datei anzeigen

@ -4,91 +4,73 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes * http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes
*/ */
public class BlendDiscBrush extends BlendBrushBase public class BlendDiscBrush extends BlendBrushBase {
{
/** /**
* *
*/ */
public BlendDiscBrush() public BlendDiscBrush() {
{
this.setName("Blend Disc"); this.setName("Blend Disc");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected final void blend(final SnipeData v) protected final void blend(final SnipeData v) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final int brushSizeDoubled = 2 * brushSize; final int brushSizeDoubled = 2 * brushSize;
final int[][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer final int[][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer
final int[][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Array that holds the blended materials final int[][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Array that holds the blended materials
// Log current materials into oldmats // Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++) for (int x = 0; x <= 2 * (brushSize + 1); x++) {
{ for (int z = 0; z <= 2 * (brushSize + 1); z++) {
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
oldMaterials[x][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize - 1 + z); oldMaterials[x][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize - 1 + z);
} }
} }
// Log current materials into newmats // Log current materials into newmats
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{
System.arraycopy(oldMaterials[x + 1], 1, newMaterials[x], 0, brushSizeDoubled + 1); System.arraycopy(oldMaterials[x + 1], 1, newMaterials[x], 0, brushSizeDoubled + 1);
} }
// Blend materials // Blend materials
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{ for (int z = 0; z <= brushSizeDoubled; z++) {
for (int z = 0; z <= brushSizeDoubled; z++)
{
final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block
int modeMatCount = 0; int modeMatCount = 0;
int modeMatId = 0; int modeMatId = 0;
boolean tiecheck = true; boolean tiecheck = true;
for (int m = -1; m <= 1; m++) for (int m = -1; m <= 1; m++) {
{ for (int n = -1; n <= 1; n++) {
for (int n = -1; n <= 1; n++) if (!(m == 0 && n == 0)) {
{
if (!(m == 0 && n == 0))
{
materialFrequency[oldMaterials[x + 1 + m][z + 1 + n]]++; materialFrequency[oldMaterials[x + 1 + m][z + 1 + n]]++;
} }
} }
} }
// Find most common neighboring material. // Find most common neighboring material.
for (BlockType type : BlockTypes.values) for (BlockType type : BlockTypes.values) {
{
int i = type.getInternalId(); int i = type.getInternalId();
if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) {
{
modeMatCount = materialFrequency[i]; modeMatCount = materialFrequency[i];
modeMatId = i; modeMatId = i;
} }
} }
// Make sure there'world not a tie for most common // Make sure there'world not a tie for most common
for (int i = 0; i < modeMatId; i++) for (int i = 0; i < modeMatId; i++) {
{
BlockType type = BlockTypes.get(i); BlockType type = BlockTypes.get(i);
if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) {
{
tiecheck = false; tiecheck = false;
} }
} }
// Record most common neighbor material for this block // Record most common neighbor material for this block
if (tiecheck) if (tiecheck) {
{
newMaterials[x][z] = modeMatId; newMaterials[x][z] = modeMatId;
} }
} }
@ -98,18 +80,13 @@ public class BlendDiscBrush extends BlendBrushBase
final double rSquared = Math.pow(brushSize + 1, 2); final double rSquared = Math.pow(brushSize + 1, 2);
// Make the changes // Make the changes
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{
final double xSquared = Math.pow(x - brushSize - 1, 2); final double xSquared = Math.pow(x - brushSize - 1, 2);
for (int z = brushSizeDoubled; z >= 0; z--) for (int z = brushSizeDoubled; z >= 0; z--) {
{ if (xSquared + Math.pow(z - brushSize - 1, 2) <= rSquared) {
if (xSquared + Math.pow(z - brushSize - 1, 2) <= rSquared) if (!(this.excludeAir && BlockTypes.get(newMaterials[x][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][z] == BlockTypes.WATER.getInternalId()))) {
{ if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][z]) {
if (!(this.excludeAir && BlockTypes.get(newMaterials[x][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][z] == BlockTypes.WATER.getInternalId())))
{
if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][z])
{
undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z)); undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z));
} }
this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), newMaterials[x][z]); this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), newMaterials[x][z]);
@ -121,10 +98,8 @@ public class BlendDiscBrush extends BlendBrushBase
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Blend Disc Parameters:"); v.sendMessage(ChatColor.GOLD + "Blend Disc Parameters:");
v.sendMessage(ChatColor.AQUA + "/b bd water -- toggle include or exclude (default) water"); v.sendMessage(ChatColor.AQUA + "/b bd water -- toggle include or exclude (default) water");
return; return;
@ -134,8 +109,7 @@ public class BlendDiscBrush extends BlendBrushBase
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.blenddisc"; return "voxelsniper.brush.blenddisc";
} }
} }

Datei anzeigen

@ -4,27 +4,22 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes * http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes
*/ */
public class BlendVoxelBrush extends BlendBrushBase public class BlendVoxelBrush extends BlendBrushBase {
{
/** /**
* *
*/ */
public BlendVoxelBrush() public BlendVoxelBrush() {
{
this.setName("Blend Voxel"); this.setName("Blend Voxel");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected final void blend(final SnipeData v) protected final void blend(final SnipeData v) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final int brushSizeDoubled = 2 * brushSize; final int brushSizeDoubled = 2 * brushSize;
// Array that holds the original materials plus a buffer // Array that holds the original materials plus a buffer
@ -33,47 +28,35 @@ public class BlendVoxelBrush extends BlendBrushBase
final int[][][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; final int[][][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1];
// Log current materials into oldmats // Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++) for (int x = 0; x <= 2 * (brushSize + 1); x++) {
{ for (int y = 0; y <= 2 * (brushSize + 1); y++) {
for (int y = 0; y <= 2 * (brushSize + 1); y++) for (int z = 0; z <= 2 * (brushSize + 1); z++) {
{
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
oldMaterials[x][y][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY() - brushSize - 1 + y, this.getTargetBlock().getZ() - brushSize - 1 + z); oldMaterials[x][y][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY() - brushSize - 1 + y, this.getTargetBlock().getZ() - brushSize - 1 + z);
} }
} }
} }
// Log current materials into newmats // Log current materials into newmats
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{ for (int y = 0; y <= brushSizeDoubled; y++) {
for (int y = 0; y <= brushSizeDoubled; y++)
{
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0, System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
brushSizeDoubled + 1); brushSizeDoubled + 1);
} }
} }
// Blend materials // Blend materials
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{ for (int y = 0; y <= brushSizeDoubled; y++) {
for (int y = 0; y <= brushSizeDoubled; y++) for (int z = 0; z <= brushSizeDoubled; z++) {
{
for (int z = 0; z <= brushSizeDoubled; z++)
{
final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block
int modeMatCount = 0; int modeMatCount = 0;
int modeMatId = 0; int modeMatId = 0;
boolean tiecheck = true; boolean tiecheck = true;
for (int m = -1; m <= 1; m++) for (int m = -1; m <= 1; m++) {
{ for (int n = -1; n <= 1; n++) {
for (int n = -1; n <= 1; n++) for (int o = -1; o <= 1; o++) {
{ if (!(m == 0 && n == 0 && o == 0)) {
for (int o = -1; o <= 1; o++)
{
if (!(m == 0 && n == 0 && o == 0))
{
materialFrequency[oldMaterials[x + 1 + m][y + 1 + n][z + 1 + o]]++; materialFrequency[oldMaterials[x + 1 + m][y + 1 + n][z + 1 + o]]++;
} }
} }
@ -81,28 +64,23 @@ public class BlendVoxelBrush extends BlendBrushBase
} }
// Find most common neighboring material. // Find most common neighboring material.
for (BlockType type : BlockTypes.values) for (BlockType type : BlockTypes.values) {
{
int i = type.getInternalId(); int i = type.getInternalId();
if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) {
{
modeMatCount = materialFrequency[i]; modeMatCount = materialFrequency[i];
modeMatId = i; modeMatId = i;
} }
} }
// Make sure there'world not a tie for most common // Make sure there'world not a tie for most common
for (int i = 0; i < modeMatId; i++) for (int i = 0; i < modeMatId; i++) {
{
BlockType type = BlockTypes.get(i); BlockType type = BlockTypes.get(i);
if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) {
{
tiecheck = false; tiecheck = false;
} }
} }
// Record most common neighbor material for this block // Record most common neighbor material for this block
if (tiecheck) if (tiecheck) {
{
newMaterials[x][y][z] = modeMatId; newMaterials[x][y][z] = modeMatId;
} }
} }
@ -112,16 +90,11 @@ public class BlendVoxelBrush extends BlendBrushBase
final Undo undo = new Undo(); final Undo undo = new Undo();
// Make the changes // Make the changes
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{ for (int y = 0; y <= brushSizeDoubled; y++) {
for (int y = 0; y <= brushSizeDoubled; y++) for (int z = brushSizeDoubled; z >= 0; z--) {
{ if (!(this.excludeAir && BlockTypes.get(newMaterials[x][y][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][y][z] == BlockTypes.WATER.getInternalId()))) {
for (int z = brushSizeDoubled; z >= 0; z--) if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][y][z]) {
{
if (!(this.excludeAir && BlockTypes.get(newMaterials[x][y][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][y][z] == BlockTypes.WATER.getInternalId())))
{
if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][y][z])
{
undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z)); undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z));
} }
this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, newMaterials[x][y][z]); this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, newMaterials[x][y][z]);
@ -134,10 +107,8 @@ public class BlendVoxelBrush extends BlendBrushBase
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Blend Voxel Parameters:"); v.sendMessage(ChatColor.GOLD + "Blend Voxel Parameters:");
v.sendMessage(ChatColor.AQUA + "/b bv water -- toggle include or exclude (default) water"); v.sendMessage(ChatColor.AQUA + "/b bv water -- toggle include or exclude (default) water");
return; return;
@ -147,8 +118,7 @@ public class BlendVoxelBrush extends BlendBrushBase
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.blendvoxel"; return "voxelsniper.brush.blendvoxel";
} }
} }

Datei anzeigen

@ -4,91 +4,73 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes * http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes
*/ */
public class BlendVoxelDiscBrush extends BlendBrushBase public class BlendVoxelDiscBrush extends BlendBrushBase {
{
/** /**
* *
*/ */
public BlendVoxelDiscBrush() public BlendVoxelDiscBrush() {
{
this.setName("Blend Voxel Disc"); this.setName("Blend Voxel Disc");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected final void blend(final SnipeData v) protected final void blend(final SnipeData v) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final int brushSizeDoubled = 2 * brushSize; final int brushSizeDoubled = 2 * brushSize;
final int[][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer final int[][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer
final int[][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Array that holds the blended materials final int[][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Array that holds the blended materials
// Log current materials into oldmats // Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++) for (int x = 0; x <= 2 * (brushSize + 1); x++) {
{ for (int z = 0; z <= 2 * (brushSize + 1); z++) {
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
oldMaterials[x][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize - 1 + z); oldMaterials[x][z] = this.getBlockIdAt(this.getTargetBlock().getX() - brushSize - 1 + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize - 1 + z);
} }
} }
// Log current materials into newmats // Log current materials into newmats
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{
System.arraycopy(oldMaterials[x + 1], 1, newMaterials[x], 0, brushSizeDoubled + 1); System.arraycopy(oldMaterials[x + 1], 1, newMaterials[x], 0, brushSizeDoubled + 1);
} }
// Blend materials // Blend materials
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{ for (int z = 0; z <= brushSizeDoubled; z++) {
for (int z = 0; z <= brushSizeDoubled; z++)
{
final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block
int modeMatCount = 0; int modeMatCount = 0;
int modeMatId = 0; int modeMatId = 0;
boolean tiecheck = true; boolean tiecheck = true;
for (int m = -1; m <= 1; m++) for (int m = -1; m <= 1; m++) {
{ for (int n = -1; n <= 1; n++) {
for (int n = -1; n <= 1; n++) if (!(m == 0 && n == 0)) {
{
if (!(m == 0 && n == 0))
{
materialFrequency[oldMaterials[x + 1 + m][z + 1 + n]]++; materialFrequency[oldMaterials[x + 1 + m][z + 1 + n]]++;
} }
} }
} }
// Find most common neighboring material. // Find most common neighboring material.
for (BlockType type : BlockTypes.values) for (BlockType type : BlockTypes.values) {
{
int i = type.getInternalId(); int i = type.getInternalId();
if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) {
{
modeMatCount = materialFrequency[i]; modeMatCount = materialFrequency[i];
modeMatId = i; modeMatId = i;
} }
} }
// Make sure there'world not a tie for most common // Make sure there'world not a tie for most common
for (int i = 0; i < modeMatId; i++) for (int i = 0; i < modeMatId; i++) {
{
BlockType type = BlockTypes.get(i); BlockType type = BlockTypes.get(i);
if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) {
{
tiecheck = false; tiecheck = false;
} }
} }
// Record most common neighbor material for this block // Record most common neighbor material for this block
if (tiecheck) if (tiecheck) {
{
newMaterials[x][z] = modeMatId; newMaterials[x][z] = modeMatId;
} }
} }
@ -97,14 +79,10 @@ public class BlendVoxelDiscBrush extends BlendBrushBase
final Undo undo = new Undo(); final Undo undo = new Undo();
// Make the changes // Make the changes
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{ for (int z = brushSizeDoubled; z >= 0; z--) {
for (int z = brushSizeDoubled; z >= 0; z--) if (!(this.excludeAir && BlockTypes.get(newMaterials[x][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][z] == BlockTypes.WATER.getInternalId()))) {
{ if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][z]) {
if (!(this.excludeAir && BlockTypes.get(newMaterials[x][z]).getMaterial().isAir()) && !(this.excludeWater && (newMaterials[x][z] == BlockTypes.WATER.getInternalId())))
{
if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][z])
{
undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z)); undo.put(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - brushSize + z));
} }
this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), newMaterials[x][z]); this.setBlockIdAt(this.getTargetBlock().getZ() - brushSize + z, this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY(), newMaterials[x][z]);
@ -117,10 +95,8 @@ public class BlendVoxelDiscBrush extends BlendBrushBase
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Blend Voxel Disc Parameters:"); v.sendMessage(ChatColor.GOLD + "Blend Voxel Disc Parameters:");
v.sendMessage(ChatColor.AQUA + "/b bvd water -- toggle include or exclude (default) water"); v.sendMessage(ChatColor.AQUA + "/b bvd water -- toggle include or exclude (default) water");
return; return;
@ -130,8 +106,7 @@ public class BlendVoxelDiscBrush extends BlendBrushBase
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.blendvoxeldisc"; return "voxelsniper.brush.blendvoxeldisc";
} }
} }

Datei anzeigen

@ -1,20 +1,18 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import java.util.Random;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import java.util.Random;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#The_Blob_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Blob_Brush
* *
* @author Giltwist * @author Giltwist
*/ */
public class BlobBrush extends PerformBrush public class BlobBrush extends PerformBrush {
{
private static final int GROW_PERCENT_DEFAULT = 1000; private static final int GROW_PERCENT_DEFAULT = 1000;
private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_MIN = 1;
private static final int GROW_PERCENT_MAX = 9999; private static final int GROW_PERCENT_MAX = 9999;
@ -25,22 +23,18 @@ public class BlobBrush extends PerformBrush
/** /**
* *
*/ */
public BlobBrush() public BlobBrush() {
{
this.setName("Blob"); this.setName("Blob");
} }
private void checkValidGrowPercent(final SnipeData v) private void checkValidGrowPercent(final SnipeData v) {
{ if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX)
{
this.growPercent = GROW_PERCENT_DEFAULT; this.growPercent = GROW_PERCENT_DEFAULT;
v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%"); v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%");
} }
} }
private void digBlob(final SnipeData v) private void digBlob(final SnipeData v) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final int brushSizeDoubled = 2 * brushSize; final int brushSizeDoubled = 2 * brushSize;
final int[][][] splat = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; final int[][][] splat = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1];
@ -49,18 +43,12 @@ public class BlobBrush extends PerformBrush
this.checkValidGrowPercent(v); this.checkValidGrowPercent(v);
// Seed the array // Seed the array
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{ for (int y = brushSizeDoubled; y >= 0; y--) {
for (int y = brushSizeDoubled; y >= 0; y--) for (int z = brushSizeDoubled; z >= 0; z--) {
{ if ((x == 0 || y == 0 | z == 0 || x == brushSizeDoubled || y == brushSizeDoubled || z == brushSizeDoubled) && this.randomGenerator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) {
for (int z = brushSizeDoubled; z >= 0; z--)
{
if ((x == 0 || y == 0 | z == 0 || x == brushSizeDoubled || y == brushSizeDoubled || z == brushSizeDoubled) && this.randomGenerator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent)
{
splat[x][y][z] = 0; splat[x][y][z] = 0;
} } else {
else
{
splat[x][y][z] = 1; splat[x][y][z] = 1;
} }
} }
@ -68,46 +56,34 @@ public class BlobBrush extends PerformBrush
} }
// Grow the seed // Grow the seed
for (int r = 0; r < brushSize; r++) for (int r = 0; r < brushSize; r++) {
{ for (int x = brushSizeDoubled; x >= 0; x--) {
for (int x = brushSizeDoubled; x >= 0; x--) for (int y = brushSizeDoubled; y >= 0; y--) {
{ for (int z = brushSizeDoubled; z >= 0; z--) {
for (int y = brushSizeDoubled; y >= 0; y--)
{
for (int z = brushSizeDoubled; z >= 0; z--)
{
tempSplat[x][y][z] = splat[x][y][z]; tempSplat[x][y][z] = splat[x][y][z];
double growCheck = 0; double growCheck = 0;
if (splat[x][y][z] == 1) if (splat[x][y][z] == 1) {
{ if (x != 0 && splat[x - 1][y][z] == 0) {
if (x != 0 && splat[x - 1][y][z] == 0)
{
growCheck++; growCheck++;
} }
if (y != 0 && splat[x][y - 1][z] == 0) if (y != 0 && splat[x][y - 1][z] == 0) {
{
growCheck++; growCheck++;
} }
if (z != 0 && splat[x][y][z - 1] == 0) if (z != 0 && splat[x][y][z - 1] == 0) {
{
growCheck++; growCheck++;
} }
if (x != 2 * brushSize && splat[x + 1][y][z] == 0) if (x != 2 * brushSize && splat[x + 1][y][z] == 0) {
{
growCheck++; growCheck++;
} }
if (y != 2 * brushSize && splat[x][y + 1][z] == 0) if (y != 2 * brushSize && splat[x][y + 1][z] == 0) {
{
growCheck++; growCheck++;
} }
if (z != 2 * brushSize && splat[x][y][z + 1] == 0) if (z != 2 * brushSize && splat[x][y][z + 1] == 0) {
{
growCheck++; growCheck++;
} }
} }
if (growCheck >= 1 && this.randomGenerator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) if (growCheck >= 1 && this.randomGenerator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) {
{
tempSplat[x][y][z] = 0; // prevent bleed into splat tempSplat[x][y][z] = 0; // prevent bleed into splat
} }
} }
@ -116,10 +92,8 @@ public class BlobBrush extends PerformBrush
// shouldn't this just be splat = tempsplat;? -Gavjenks // shouldn't this just be splat = tempsplat;? -Gavjenks
// integrate tempsplat back into splat at end of iteration // integrate tempsplat back into splat at end of iteration
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{ for (int y = brushSizeDoubled; y >= 0; y--) {
for (int y = brushSizeDoubled; y >= 0; y--)
{
System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, brushSizeDoubled + 1); System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, brushSizeDoubled + 1);
} }
} }
@ -128,18 +102,14 @@ public class BlobBrush extends PerformBrush
final double rSquared = Math.pow(brushSize + 1, 2); final double rSquared = Math.pow(brushSize + 1, 2);
// Make the changes // Make the changes
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{
final double xSquared = Math.pow(x - brushSize - 1, 2); final double xSquared = Math.pow(x - brushSize - 1, 2);
for (int y = brushSizeDoubled; y >= 0; y--) for (int y = brushSizeDoubled; y >= 0; y--) {
{
final double ySquared = Math.pow(y - brushSize - 1, 2); final double ySquared = Math.pow(y - brushSize - 1, 2);
for (int z = brushSizeDoubled; z >= 0; z--) for (int z = brushSizeDoubled; z >= 0; z--) {
{ if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared) {
if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared)
{
this.current.perform(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + z, this.getTargetBlock().getZ() - brushSize + y)); this.current.perform(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + z, this.getTargetBlock().getZ() - brushSize + y));
} }
} }
@ -149,8 +119,7 @@ public class BlobBrush extends PerformBrush
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void growBlob(final SnipeData v) private void growBlob(final SnipeData v) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final int brushSizeDoubled = 2 * brushSize; final int brushSizeDoubled = 2 * brushSize;
final int[][][] splat = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1]; final int[][][] splat = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1];
@ -162,47 +131,35 @@ public class BlobBrush extends PerformBrush
splat[brushSize][brushSize][brushSize] = 1; splat[brushSize][brushSize][brushSize] = 1;
// Grow the seed // Grow the seed
for (int r = 0; r < brushSize; r++) for (int r = 0; r < brushSize; r++) {
{
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{ for (int y = brushSizeDoubled; y >= 0; y--) {
for (int y = brushSizeDoubled; y >= 0; y--) for (int z = brushSizeDoubled; z >= 0; z--) {
{
for (int z = brushSizeDoubled; z >= 0; z--)
{
tempSplat[x][y][z] = splat[x][y][z]; tempSplat[x][y][z] = splat[x][y][z];
int growCheck = 0; int growCheck = 0;
if (splat[x][y][z] == 0) if (splat[x][y][z] == 0) {
{ if (x != 0 && splat[x - 1][y][z] == 1) {
if (x != 0 && splat[x - 1][y][z] == 1)
{
growCheck++; growCheck++;
} }
if (y != 0 && splat[x][y - 1][z] == 1) if (y != 0 && splat[x][y - 1][z] == 1) {
{
growCheck++; growCheck++;
} }
if (z != 0 && splat[x][y][z - 1] == 1) if (z != 0 && splat[x][y][z - 1] == 1) {
{
growCheck++; growCheck++;
} }
if (x != 2 * brushSize && splat[x + 1][y][z] == 1) if (x != 2 * brushSize && splat[x + 1][y][z] == 1) {
{
growCheck++; growCheck++;
} }
if (y != 2 * brushSize && splat[x][y + 1][z] == 1) if (y != 2 * brushSize && splat[x][y + 1][z] == 1) {
{
growCheck++; growCheck++;
} }
if (z != 2 * brushSize && splat[x][y][z + 1] == 1) if (z != 2 * brushSize && splat[x][y][z + 1] == 1) {
{
growCheck++; growCheck++;
} }
} }
if (growCheck >= 1 && this.randomGenerator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) if (growCheck >= 1 && this.randomGenerator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) {
{
// prevent bleed into splat // prevent bleed into splat
tempSplat[x][y][z] = 1; tempSplat[x][y][z] = 1;
} }
@ -211,10 +168,8 @@ public class BlobBrush extends PerformBrush
} }
// integrate tempsplat back into splat at end of iteration // integrate tempsplat back into splat at end of iteration
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{ for (int y = brushSizeDoubled; y >= 0; y--) {
for (int y = brushSizeDoubled; y >= 0; y--)
{
System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, brushSizeDoubled + 1); System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, brushSizeDoubled + 1);
} }
} }
@ -223,18 +178,14 @@ public class BlobBrush extends PerformBrush
final double rSquared = Math.pow(brushSize + 1, 2); final double rSquared = Math.pow(brushSize + 1, 2);
// Make the changes // Make the changes
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{
final double xSquared = Math.pow(x - brushSize - 1, 2); final double xSquared = Math.pow(x - brushSize - 1, 2);
for (int y = brushSizeDoubled; y >= 0; y--) for (int y = brushSizeDoubled; y >= 0; y--) {
{
final double ySquared = Math.pow(y - brushSize - 1, 2); final double ySquared = Math.pow(y - brushSize - 1, 2);
for (int z = brushSizeDoubled; z >= 0; z--) for (int z = brushSizeDoubled; z >= 0; z--) {
{ if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared) {
if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared)
{
this.current.perform(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + z, this.getTargetBlock().getZ() - brushSize + y)); this.current.perform(this.clampY(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + z, this.getTargetBlock().getZ() - brushSize + y));
} }
} }
@ -245,20 +196,17 @@ public class BlobBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.growBlob(v); this.growBlob(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.digBlob(v); this.digBlob(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
this.checkValidGrowPercent(null); this.checkValidGrowPercent(null);
vm.brushName(this.getName()); vm.brushName(this.getName());
@ -267,41 +215,31 @@ public class BlobBrush extends PerformBrush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Blob brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Blob brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b blob g[int] -- set a growth percentage (" + GROW_PERCENT_MIN + "-" + GROW_PERCENT_MAX + "). Default is " + GROW_PERCENT_DEFAULT); v.sendMessage(ChatColor.AQUA + "/b blob g[int] -- set a growth percentage (" + GROW_PERCENT_MIN + "-" + GROW_PERCENT_MAX + "). Default is " + GROW_PERCENT_DEFAULT);
return; return;
} }
if (parameter.startsWith("g")) if (parameter.startsWith("g")) {
{
final int temp = Integer.parseInt(parameter.replace("g", "")); final int temp = Integer.parseInt(parameter.replace("g", ""));
if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + (float) temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + (float) temp / 100 + "%");
this.growPercent = temp; this.growPercent = temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Growth percent must be an integer " + GROW_PERCENT_MIN + "-" + GROW_PERCENT_MAX + "!"); v.sendMessage(ChatColor.RED + "Growth percent must be an integer " + GROW_PERCENT_MIN + "-" + GROW_PERCENT_MAX + "!");
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.blob"; return "voxelsniper.brush.blob";
} }
} }

Datei anzeigen

@ -1,22 +1,19 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import java.util.ArrayList;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import java.util.ArrayList;
/** /**
* @author MikeMatrix * @author MikeMatrix
*/ */
public class BlockResetBrush extends Brush public class BlockResetBrush extends Brush {
{
private static final ArrayList<Material> DENIED_UPDATES = new ArrayList<>(); private static final ArrayList<Material> DENIED_UPDATES = new ArrayList<>();
static static {
{
BlockResetBrush.DENIED_UPDATES.add(Material.SIGN); BlockResetBrush.DENIED_UPDATES.add(Material.SIGN);
BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_SIGN_POST); BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_SIGN_POST);
BlockResetBrush.DENIED_UPDATES.add(Material.WALL_SIGN); BlockResetBrush.DENIED_UPDATES.add(Material.WALL_SIGN);
@ -38,23 +35,17 @@ public class BlockResetBrush extends Brush
/** /**
* *
*/ */
public BlockResetBrush() public BlockResetBrush() {
{
this.setName("Block Reset Brush"); this.setName("Block Reset Brush");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void applyBrush(final SnipeData v) private void applyBrush(final SnipeData v) {
{ for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) {
for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) {
{ for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++) {
for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++)
{
for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++)
{
final Block block = this.getWorld().getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z); final Block block = this.getWorld().getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z);
if (BlockResetBrush.DENIED_UPDATES.contains(block.getType())) if (BlockResetBrush.DENIED_UPDATES.contains(block.getType())) {
{
continue; continue;
} }
@ -65,26 +56,22 @@ public class BlockResetBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
applyBrush(v); applyBrush(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
applyBrush(v); applyBrush(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.blockreset"; return "voxelsniper.brush.blockreset";
} }
} }

Datei anzeigen

@ -1,17 +1,12 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import java.util.ArrayList;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.boydti.fawe.bukkit.wrapper.AsyncWorld; import com.boydti.fawe.bukkit.wrapper.AsyncWorld;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
/** /**
* This brush only looks for solid blocks, and then changes those plus any air blocks touching them. If it works, this brush should be faster than the original * This brush only looks for solid blocks, and then changes those plus any air blocks touching them. If it works, this brush should be faster than the original
@ -28,90 +23,76 @@ import org.bukkit.block.Block;
* *
* @author GavJenks * @author GavJenks
*/ */
public class BlockResetSurfaceBrush extends Brush public class BlockResetSurfaceBrush extends Brush {
{
/** /**
* *
*/ */
public BlockResetSurfaceBrush() public BlockResetSurfaceBrush() {
{
this.setName("Block Reset Brush Surface Only"); this.setName("Block Reset Brush Surface Only");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void applyBrush(final SnipeData v) private void applyBrush(final SnipeData v) {
{
final AsyncWorld world = this.getWorld(); final AsyncWorld world = this.getWorld();
for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) {
{ for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) {
for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++) {
{
for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++)
{
AsyncBlock block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z); AsyncBlock block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z);
Material type = block.getType(); Material type = block.getType();
BlockMaterial mat = BukkitAdapter.adapt(type).getMaterial(); BlockMaterial mat = BukkitAdapter.adapt(type).getMaterial();
if (!mat.isSolid() || !mat.isFullCube() || mat.hasContainer()) if (!mat.isSolid() || !mat.isFullCube() || mat.hasContainer()) {
{
continue; continue;
} }
boolean airFound = false; boolean airFound = false;
if (world.getBlockAt(this.getTargetBlock().getX() + x + 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z).isEmpty()) if (world.getBlockAt(this.getTargetBlock().getX() + x + 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z).isEmpty()) {
{
block = world.getBlockAt(this.getTargetBlock().getX() + x + 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z); block = world.getBlockAt(this.getTargetBlock().getX() + x + 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z);
final int oldData = block.getPropertyId(); final int oldData = block.getPropertyId();
resetBlock(block, oldData); resetBlock(block, oldData);
airFound = true; airFound = true;
} }
if (world.getBlockAt(this.getTargetBlock().getX() + x - 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z).isEmpty()) if (world.getBlockAt(this.getTargetBlock().getX() + x - 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z).isEmpty()) {
{
block = world.getBlockAt(this.getTargetBlock().getX() + x - 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z); block = world.getBlockAt(this.getTargetBlock().getX() + x - 1, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z);
final int oldData = block.getPropertyId(); final int oldData = block.getPropertyId();
resetBlock(block, oldData); resetBlock(block, oldData);
airFound = true; airFound = true;
} }
if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y + 1, this.getTargetBlock().getZ() + z).isEmpty()) if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y + 1, this.getTargetBlock().getZ() + z).isEmpty()) {
{
block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y + 1, this.getTargetBlock().getZ() + z); block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y + 1, this.getTargetBlock().getZ() + z);
final int oldData = block.getPropertyId(); final int oldData = block.getPropertyId();
resetBlock(block, oldData); resetBlock(block, oldData);
airFound = true; airFound = true;
} }
if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y - 1, this.getTargetBlock().getZ() + z).isEmpty()) if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y - 1, this.getTargetBlock().getZ() + z).isEmpty()) {
{
block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y - 1, this.getTargetBlock().getZ() + z); block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y - 1, this.getTargetBlock().getZ() + z);
final int oldData = block.getPropertyId(); final int oldData = block.getPropertyId();
resetBlock(block, oldData); resetBlock(block, oldData);
airFound = true; airFound = true;
} }
if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z + 1).isEmpty()) if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z + 1).isEmpty()) {
{
block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z + 1); block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z + 1);
final int oldData = block.getPropertyId(); final int oldData = block.getPropertyId();
resetBlock(block, oldData); resetBlock(block, oldData);
airFound = true; airFound = true;
} }
if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z - 1).isEmpty()) if (world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z - 1).isEmpty()) {
{
block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z - 1); block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z - 1);
final int oldData = block.getPropertyId(); final int oldData = block.getPropertyId();
resetBlock(block, oldData); resetBlock(block, oldData);
airFound = true; airFound = true;
} }
if (airFound) if (airFound) {
{
block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z); block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z);
final int oldData = block.getPropertyId(); final int oldData = block.getPropertyId();
resetBlock(block, oldData); resetBlock(block, oldData);
@ -122,33 +103,28 @@ public class BlockResetSurfaceBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void resetBlock(AsyncBlock block, final int oldData) private void resetBlock(AsyncBlock block, final int oldData) {
{ block.setTypeIdAndPropertyId(block.getTypeId(), ((block.getPropertyId() + 1) & 0xf), true);
block.setTypeIdAndPropertyId(block.getTypeId(), ((block.getPropertyId() + 1) & 0xf), true);
block.setTypeIdAndPropertyId(block.getTypeId(), oldData, true); block.setTypeIdAndPropertyId(block.getTypeId(), oldData, true);
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
applyBrush(v); applyBrush(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
applyBrush(v); applyBrush(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.blockresetsurface"; return "voxelsniper.brush.blockresetsurface";
} }
} }

Datei anzeigen

@ -11,15 +11,13 @@ import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import com.thevoxelbox.voxelsniper.util.BlockWrapper; import com.thevoxelbox.voxelsniper.util.BlockWrapper;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
/** /**
* Abstract implementation of the {@link IBrush} interface. * Abstract implementation of the {@link IBrush} interface.
*/ */
public abstract class Brush implements IBrush public abstract class Brush implements IBrush {
{
protected static final int CHUNK_SIZE = 16; protected static final int CHUNK_SIZE = 16;
/** /**
* Targeted Block. * Targeted Block.
@ -40,27 +38,20 @@ public abstract class Brush implements IBrush
* @param z * @param z
* @return {@link Block} * @return {@link Block}
*/ */
public final AsyncBlock clampY(final int x, final int y, final int z) public final AsyncBlock clampY(final int x, final int y, final int z) {
{
int clampedY = y; int clampedY = y;
if (clampedY < 0) if (clampedY < 0) {
{
clampedY = 0; clampedY = 0;
} } else if (clampedY > this.getWorld().getMaxHeight()) {
else if (clampedY > this.getWorld().getMaxHeight())
{
clampedY = this.getWorld().getMaxHeight(); clampedY = this.getWorld().getMaxHeight();
} }
return this.getWorld().getBlockAt(x, clampedY, z); return this.getWorld().getBlockAt(x, clampedY, z);
} }
private boolean preparePerform(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace) private boolean preparePerform(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace) {
{ if (this.getTarget(v, clickedBlock, clickedFace)) {
if (this.getTarget(v, clickedBlock, clickedFace)) if (this instanceof PerformBrush) {
{
if (this instanceof PerformBrush)
{
((PerformBrush) this).initP(v); ((PerformBrush) this).initP(v);
} }
return true; return true;
@ -70,12 +61,10 @@ public abstract class Brush implements IBrush
} }
@Override @Override
public boolean perform(SnipeAction action, SnipeData data, AsyncBlock targetBlock, AsyncBlock lastBlock) public boolean perform(SnipeAction action, SnipeData data, AsyncBlock targetBlock, AsyncBlock lastBlock) {
{
this.setTargetBlock(targetBlock); this.setTargetBlock(targetBlock);
this.setLastBlock(lastBlock); this.setLastBlock(lastBlock);
switch (action) switch (action) {
{
case ARROW: case ARROW:
this.arrow(data); this.arrow(data);
return true; return true;
@ -92,8 +81,7 @@ public abstract class Brush implements IBrush
* *
* @param v Sniper caller * @param v Sniper caller
*/ */
protected void arrow(final SnipeData v) protected void arrow(final SnipeData v) {
{
} }
/** /**
@ -101,16 +89,14 @@ public abstract class Brush implements IBrush
* *
* @param v Sniper caller * @param v Sniper caller
*/ */
protected void powder(final SnipeData v) protected void powder(final SnipeData v) {
{
} }
@Override @Override
public abstract void info(Message vm); public abstract void info(Message vm);
@Override @Override
public void parameters(final String[] par, final SnipeData v) public void parameters(final String[] par, final SnipeData v) {
{
v.sendMessage(ChatColor.RED + "This brush does not accept additional parameters."); v.sendMessage(ChatColor.RED + "This brush does not accept additional parameters.");
} }
@ -122,52 +108,38 @@ public abstract class Brush implements IBrush
* @param clickedFace * @param clickedFace
* @return boolean * @return boolean
*/ */
protected final boolean getTarget(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace) protected final boolean getTarget(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace) {
{ if (clickedBlock != null) {
if (clickedBlock != null)
{
this.setTargetBlock(clickedBlock); this.setTargetBlock(clickedBlock);
this.setLastBlock(clickedBlock.getRelative(clickedFace)); this.setLastBlock(clickedBlock.getRelative(clickedFace));
if (this.getLastBlock() == null) if (this.getLastBlock() == null) {
{
v.sendMessage(ChatColor.RED + "Snipe target block must be visible."); v.sendMessage(ChatColor.RED + "Snipe target block must be visible.");
return false; return false;
} }
if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isLightningEnabled()) if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isLightningEnabled()) {
{
this.getWorld().strikeLightning(this.getTargetBlock().getLocation()); this.getWorld().strikeLightning(this.getTargetBlock().getLocation());
} }
return true; return true;
} } else {
else
{
RangeBlockHelper rangeBlockHelper; RangeBlockHelper rangeBlockHelper;
if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isRanged()) if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isRanged()) {
{
rangeBlockHelper = new RangeBlockHelper(v.owner().getPlayer(), v.owner().getWorld(), (double) v.owner().getSnipeData(v.owner().getCurrentToolId()).getRange()); rangeBlockHelper = new RangeBlockHelper(v.owner().getPlayer(), v.owner().getWorld(), (double) v.owner().getSnipeData(v.owner().getCurrentToolId()).getRange());
this.setTargetBlock(rangeBlockHelper.getRangeBlock()); this.setTargetBlock(rangeBlockHelper.getRangeBlock());
} } else {
else
{
rangeBlockHelper = new RangeBlockHelper(v.owner().getPlayer(), v.owner().getWorld()); rangeBlockHelper = new RangeBlockHelper(v.owner().getPlayer(), v.owner().getWorld());
this.setTargetBlock(rangeBlockHelper.getTargetBlock()); this.setTargetBlock(rangeBlockHelper.getTargetBlock());
} }
if (this.getTargetBlock() != null) if (this.getTargetBlock() != null) {
{
this.setLastBlock(rangeBlockHelper.getLastBlock()); this.setLastBlock(rangeBlockHelper.getLastBlock());
if (this.getLastBlock() == null) if (this.getLastBlock() == null) {
{
v.sendMessage(ChatColor.RED + "Snipe target block must be visible."); v.sendMessage(ChatColor.RED + "Snipe target block must be visible.");
return false; return false;
} }
if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isLightningEnabled()) if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isLightningEnabled()) {
{
this.getWorld().strikeLightning(this.getTargetBlock().getLocation()); this.getWorld().strikeLightning(this.getTargetBlock().getLocation());
} }
return true; return true;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Snipe target block must be visible."); v.sendMessage(ChatColor.RED + "Snipe target block must be visible.");
return false; return false;
} }
@ -175,44 +147,38 @@ public abstract class Brush implements IBrush
} }
@Override @Override
public final String getName() public final String getName() {
{
return this.name; return this.name;
} }
@Override @Override
public final void setName(final String name) public final void setName(final String name) {
{
this.name = name; this.name = name;
} }
@Override @Override
public String getBrushCategory() public String getBrushCategory() {
{
return "General"; return "General";
} }
/** /**
* @return the targetBlock * @return the targetBlock
*/ */
protected final AsyncBlock getTargetBlock() protected final AsyncBlock getTargetBlock() {
{
return this.targetBlock; return this.targetBlock;
} }
/** /**
* @param targetBlock the targetBlock to set * @param targetBlock the targetBlock to set
*/ */
protected final void setTargetBlock(final AsyncBlock targetBlock) protected final void setTargetBlock(final AsyncBlock targetBlock) {
{
this.targetBlock = targetBlock; this.targetBlock = targetBlock;
} }
/** /**
* @return the world * @return the world
*/ */
protected final AsyncWorld getWorld() protected final AsyncWorld getWorld() {
{
return targetBlock.getWorld(); return targetBlock.getWorld();
} }
@ -225,18 +191,15 @@ public abstract class Brush implements IBrush
* @return Type ID of Block at given coordinates in the world of the targeted Block. * @return Type ID of Block at given coordinates in the world of the targeted Block.
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected int getBlockIdAt(int x, int y, int z) protected int getBlockIdAt(int x, int y, int z) {
{
return getWorld().getBlockAt(x, y, z).getTypeId(); return getWorld().getBlockAt(x, y, z).getTypeId();
} }
protected Block getBlockAt(int x, int y, int z) protected Block getBlockAt(int x, int y, int z) {
{
return getWorld().getBlockAt(x, y, z); return getWorld().getBlockAt(x, y, z);
} }
protected Material getBlockType(int x, int y, int z) protected Material getBlockType(int x, int y, int z) {
{
return getWorld().getBlockAt(x, y, z).getType(); return getWorld().getBlockAt(x, y, z).getType();
} }
@ -249,24 +212,21 @@ public abstract class Brush implements IBrush
* @return Block Data Value of Block at given coordinates in the world of the targeted Block. * @return Block Data Value of Block at given coordinates in the world of the targeted Block.
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected int getBlockDataAt(int x, int y, int z) protected int getBlockDataAt(int x, int y, int z) {
{
return this.getWorld().getBlockAt(x, y, z).getPropertyId(); return this.getWorld().getBlockAt(x, y, z).getPropertyId();
} }
/** /**
* @return Block before target Block. * @return Block before target Block.
*/ */
protected final AsyncBlock getLastBlock() protected final AsyncBlock getLastBlock() {
{
return this.lastBlock; return this.lastBlock;
} }
/** /**
* @param lastBlock Last Block before target Block. * @param lastBlock Last Block before target Block.
*/ */
protected final void setLastBlock(AsyncBlock lastBlock) protected final void setLastBlock(AsyncBlock lastBlock) {
{
this.lastBlock = lastBlock; this.lastBlock = lastBlock;
} }
@ -276,8 +236,7 @@ public abstract class Brush implements IBrush
* @param blockWrapper Block data wrapper * @param blockWrapper Block data wrapper
*/ */
@Deprecated @Deprecated
protected final void setBlock(BlockWrapper blockWrapper) protected final void setBlock(BlockWrapper blockWrapper) {
{
this.getWorld().getBlockAt(blockWrapper.getX(), blockWrapper.getY(), blockWrapper.getZ()).setTypeId(blockWrapper.getId()); this.getWorld().getBlockAt(blockWrapper.getX(), blockWrapper.getY(), blockWrapper.getZ()).setTypeId(blockWrapper.getId());
} }
@ -290,8 +249,7 @@ public abstract class Brush implements IBrush
* @param id The id the block will be set to * @param id The id the block will be set to
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected final void setBlockIdAt(int z, int x, int y, int id) protected final void setBlockIdAt(int z, int x, int y, int id) {
{
this.getWorld().getBlockAt(x, y, z).setTypeId(id); this.getWorld().getBlockAt(x, y, z).setTypeId(id);
} }
@ -305,8 +263,7 @@ public abstract class Brush implements IBrush
* @param data The data value the block will be set to * @param data The data value the block will be set to
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected final void setBlockIdAndDataAt(int x, int y, int z, int id, int data) protected final void setBlockIdAndDataAt(int x, int y, int z, int id, int data) {
{
this.getWorld().getBlockAt(x, y, z).setTypeIdAndPropertyId(id, data, true); this.getWorld().getBlockAt(x, y, z).setTypeIdAndPropertyId(id, data, true);
} }
@ -320,8 +277,7 @@ public abstract class Brush implements IBrush
* @param data The data value the block will be set to * @param data The data value the block will be set to
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected final void setBlockLegacy(int x, int y, int z, int id, int data) protected final void setBlockLegacy(int x, int y, int z, int id, int data) {
{
this.getWorld().getBlockAt(x, y, z).setCombinedId(LegacyMapper.getInstance().getBlockFromLegacy(id, data).getInternalId()); this.getWorld().getBlockAt(x, y, z).setCombinedId(LegacyMapper.getInstance().getBlockFromLegacy(id, data).getInternalId());
} }
} }

Datei anzeigen

@ -16,8 +16,7 @@ import org.bukkit.block.Block;
* *
* @author Voxel * @author Voxel
*/ */
public class CanyonBrush extends Brush public class CanyonBrush extends Brush {
{
private static final int SHIFT_LEVEL_MIN = 10; private static final int SHIFT_LEVEL_MIN = 10;
private static final int SHIFT_LEVEL_MAX = 60; private static final int SHIFT_LEVEL_MAX = 60;
private int yLevel = 10; private int yLevel = 10;
@ -25,8 +24,7 @@ public class CanyonBrush extends Brush
/** /**
* *
*/ */
public CanyonBrush() public CanyonBrush() {
{
this.setName("Canyon"); this.setName("Canyon");
} }
@ -35,16 +33,12 @@ public class CanyonBrush extends Brush
* @param undo * @param undo
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected final void canyon(final AsyncChunk chunk, final Undo undo) protected final void canyon(final AsyncChunk chunk, final Undo undo) {
{ for (int x = 0; x < CHUNK_SIZE; x++) {
for (int x = 0; x < CHUNK_SIZE; x++) for (int z = 0; z < CHUNK_SIZE; z++) {
{
for (int z = 0; z < CHUNK_SIZE; z++)
{
int currentYLevel = this.yLevel; int currentYLevel = this.yLevel;
for (int y = 63; y < this.getWorld().getMaxHeight(); y++) for (int y = 63; y < this.getWorld().getMaxHeight(); y++) {
{
final AsyncBlock block = chunk.getBlock(x, y, z); final AsyncBlock block = chunk.getBlock(x, y, z);
final AsyncBlock currentYLevelBlock = chunk.getBlock(x, currentYLevel, z); final AsyncBlock currentYLevelBlock = chunk.getBlock(x, currentYLevel, z);
@ -61,8 +55,7 @@ public class CanyonBrush extends Brush
undo.put(block); undo.put(block);
block.setTypeId(BlockTypes.BEDROCK.getInternalId()); block.setTypeId(BlockTypes.BEDROCK.getInternalId());
for (int y = 1; y < SHIFT_LEVEL_MIN; y++) for (int y = 1; y < SHIFT_LEVEL_MIN; y++) {
{
final Block currentBlock = chunk.getBlock(x, y, z); final Block currentBlock = chunk.getBlock(x, y, z);
undo.put(currentBlock); undo.put(currentBlock);
currentBlock.setType(Material.STONE); currentBlock.setType(Material.STONE);
@ -72,8 +65,7 @@ public class CanyonBrush extends Brush
} }
@Override @Override
protected void arrow(final SnipeData v) protected void arrow(final SnipeData v) {
{
final Undo undo = new Undo(); final Undo undo = new Undo();
canyon(getTargetBlock().getChunk(), undo); canyon(getTargetBlock().getChunk(), undo);
@ -82,15 +74,12 @@ public class CanyonBrush extends Brush
} }
@Override @Override
protected void powder(final SnipeData v) protected void powder(final SnipeData v) {
{
final Undo undo = new Undo(); final Undo undo = new Undo();
Chunk targetChunk = getTargetBlock().getChunk(); Chunk targetChunk = getTargetBlock().getChunk();
for (int x = targetChunk.getX() - 1; x <= targetChunk.getX() + 1; x++) for (int x = targetChunk.getX() - 1; x <= targetChunk.getX() + 1; x++) {
{ for (int z = targetChunk.getX() - 1; z <= targetChunk.getX() + 1; z++) {
for (int z = targetChunk.getX() - 1; z <= targetChunk.getX() + 1; z++)
{
canyon(getWorld().getChunkAt(x, z), undo); canyon(getWorld().getChunkAt(x, z), undo);
} }
} }
@ -99,28 +88,21 @@ public class CanyonBrush extends Brush
} }
@Override @Override
public void info(final Message vm) public void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.GREEN + "Shift Level set to " + this.yLevel); vm.custom(ChatColor.GREEN + "Shift Level set to " + this.yLevel);
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GREEN + "y[number] to set the Level to which the land will be shifted down"); v.sendMessage(ChatColor.GREEN + "y[number] to set the Level to which the land will be shifted down");
} }
if (par[1].startsWith("y")) if (par[1].startsWith("y")) {
{
int _i = Integer.parseInt(par[1].replace("y", "")); int _i = Integer.parseInt(par[1].replace("y", ""));
if (_i < SHIFT_LEVEL_MIN) if (_i < SHIFT_LEVEL_MIN) {
{
_i = SHIFT_LEVEL_MIN; _i = SHIFT_LEVEL_MIN;
} } else if (_i > SHIFT_LEVEL_MAX) {
else if (_i > SHIFT_LEVEL_MAX)
{
_i = SHIFT_LEVEL_MAX; _i = SHIFT_LEVEL_MAX;
} }
this.yLevel = _i; this.yLevel = _i;
@ -128,19 +110,16 @@ public class CanyonBrush extends Brush
} }
} }
protected final int getYLevel() protected final int getYLevel() {
{
return yLevel; return yLevel;
} }
protected final void setYLevel(int yLevel) protected final void setYLevel(int yLevel) {
{
this.yLevel = yLevel; this.yLevel = yLevel;
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.canyon"; return "voxelsniper.brush.canyon";
} }
} }

Datei anzeigen

@ -11,8 +11,7 @@ import org.bukkit.Chunk;
* *
* @author Voxel * @author Voxel
*/ */
public class CanyonSelectionBrush extends CanyonBrush public class CanyonSelectionBrush extends CanyonBrush {
{
private boolean first = true; private boolean first = true;
private int fx; private int fx;
private int fz; private int fz;
@ -20,25 +19,20 @@ public class CanyonSelectionBrush extends CanyonBrush
/** /**
* *
*/ */
public CanyonSelectionBrush() public CanyonSelectionBrush() {
{
this.setName("Canyon Selection"); this.setName("Canyon Selection");
} }
private void execute(final SnipeData v) private void execute(final SnipeData v) {
{
final Chunk chunk = getTargetBlock().getChunk(); final Chunk chunk = getTargetBlock().getChunk();
if (this.first) if (this.first) {
{
this.fx = chunk.getX(); this.fx = chunk.getX();
this.fz = chunk.getZ(); this.fz = chunk.getZ();
v.sendMessage(ChatColor.YELLOW + "First point selected!"); v.sendMessage(ChatColor.YELLOW + "First point selected!");
this.first = !this.first; this.first = !this.first;
} } else {
else
{
v.sendMessage(ChatColor.YELLOW + "Second point selected!"); v.sendMessage(ChatColor.YELLOW + "Second point selected!");
selection(Math.min(fx, chunk.getX()), Math.min(fz, chunk.getZ()), Math.max(fx, chunk.getX()), Math.max(fz, chunk.getZ()), v); selection(Math.min(fx, chunk.getX()), Math.min(fz, chunk.getZ()), Math.max(fx, chunk.getX()), Math.max(fz, chunk.getZ()), v);
@ -46,14 +40,11 @@ public class CanyonSelectionBrush extends CanyonBrush
} }
} }
private void selection(final int lowX, final int lowZ, final int highX, final int highZ, final SnipeData v) private void selection(final int lowX, final int lowZ, final int highX, final int highZ, final SnipeData v) {
{
final Undo undo = new Undo(); final Undo undo = new Undo();
for (int x = lowX; x <= highX; x++) for (int x = lowX; x <= highX; x++) {
{ for (int z = lowZ; z <= highZ; z++) {
for (int z = lowZ; z <= highZ; z++)
{
canyon(getWorld().getChunkAt(x, z), undo); canyon(getWorld().getChunkAt(x, z), undo);
} }
} }
@ -62,27 +53,23 @@ public class CanyonSelectionBrush extends CanyonBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
execute(v); execute(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
execute(v); execute(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.GREEN + "Shift Level set to " + this.getYLevel()); vm.custom(ChatColor.GREEN + "Shift Level set to " + this.getYLevel());
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.canyonselection"; return "voxelsniper.brush.canyonselection";
} }
} }

Datei anzeigen

@ -3,22 +3,19 @@ package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block; import org.bukkit.block.Block;
/** /**
* @author MikeMatrix * @author MikeMatrix
*/ */
public class CheckerVoxelDiscBrush extends PerformBrush public class CheckerVoxelDiscBrush extends PerformBrush {
{
private boolean useWorldCoordinates = true; private boolean useWorldCoordinates = true;
/** /**
* Default constructor. * Default constructor.
*/ */
public CheckerVoxelDiscBrush() public CheckerVoxelDiscBrush() {
{
this.setName("Checker Voxel Disc"); this.setName("Checker Voxel Disc");
} }
@ -26,15 +23,11 @@ public class CheckerVoxelDiscBrush extends PerformBrush
* @param v * @param v
* @param target * @param target
*/ */
private void applyBrush(final SnipeData v, final Block target) private void applyBrush(final SnipeData v, final Block target) {
{ for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) {
{
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--)
{
final int sum = this.useWorldCoordinates ? target.getX() + x + target.getZ() + y : x + y; final int sum = this.useWorldCoordinates ? target.getX() + x + target.getZ() + y : x + y;
if (sum % 2 != 0) if (sum % 2 != 0) {
{
this.current.perform(this.clampY(target.getX() + x, target.getY(), target.getZ() + y)); this.current.perform(this.clampY(target.getX() + x, target.getY(), target.getZ() + y));
} }
} }
@ -43,50 +36,39 @@ public class CheckerVoxelDiscBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.applyBrush(v, this.getTargetBlock()); this.applyBrush(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.applyBrush(v, this.getLastBlock()); this.applyBrush(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int x = 1; x < par.length; x++) {
for (int x = 1; x < par.length; x++)
{
final String parameter = par[x].toLowerCase(); final String parameter = par[x].toLowerCase();
if (parameter.equals("info")) if (parameter.equals("info")) {
{
v.sendMessage(ChatColor.GOLD + this.getName() + " Parameters:"); v.sendMessage(ChatColor.GOLD + this.getName() + " Parameters:");
v.sendMessage(ChatColor.AQUA + "true -- Enables using World Coordinates."); v.sendMessage(ChatColor.AQUA + "true -- Enables using World Coordinates.");
v.sendMessage(ChatColor.AQUA + "false -- Disables using World Coordinates."); v.sendMessage(ChatColor.AQUA + "false -- Disables using World Coordinates.");
return; return;
} }
if (parameter.startsWith("true")) if (parameter.startsWith("true")) {
{
this.useWorldCoordinates = true; this.useWorldCoordinates = true;
v.sendMessage(ChatColor.AQUA + "Enabled using World Coordinates."); v.sendMessage(ChatColor.AQUA + "Enabled using World Coordinates.");
} } else if (parameter.startsWith("false")) {
else if (parameter.startsWith("false"))
{
this.useWorldCoordinates = false; this.useWorldCoordinates = false;
v.sendMessage(ChatColor.AQUA + "Disabled using World Coordinates."); v.sendMessage(ChatColor.AQUA + "Disabled using World Coordinates.");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
break; break;
} }
@ -94,8 +76,7 @@ public class CheckerVoxelDiscBrush extends PerformBrush
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.checkervoxeldisc"; return "voxelsniper.brush.checkervoxeldisc";
} }
} }

Datei anzeigen

@ -4,7 +4,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -13,38 +12,30 @@ import org.bukkit.Material;
* *
* @author psanker * @author psanker
*/ */
public class CleanSnowBrush extends Brush public class CleanSnowBrush extends Brush {
{
private double trueCircle = 0; private double trueCircle = 0;
/** /**
* *
*/ */
public CleanSnowBrush() public CleanSnowBrush() {
{
this.setName("Clean Snow"); this.setName("Clean Snow");
} }
private void cleanSnow(final SnipeData v) private void cleanSnow(final SnipeData v) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
final Undo undo = new Undo(); final Undo undo = new Undo();
for (int y = (brushSize + 1) * 2; y >= 0; y--) for (int y = (brushSize + 1) * 2; y >= 0; y--) {
{
final double ySquared = Math.pow(y - brushSize, 2); final double ySquared = Math.pow(y - brushSize, 2);
for (int x = (brushSize + 1) * 2; x >= 0; x--) for (int x = (brushSize + 1) * 2; x >= 0; x--) {
{
final double xSquared = Math.pow(x - brushSize, 2); final double xSquared = Math.pow(x - brushSize, 2);
for (int z = (brushSize + 1) * 2; z >= 0; z--) for (int z = (brushSize + 1) * 2; z >= 0; z--) {
{ if ((xSquared + Math.pow(z - brushSize, 2) + ySquared) <= brushSizeSquared) {
if ((xSquared + Math.pow(z - brushSize, 2) + ySquared) <= brushSizeSquared) if ((this.clampY(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, this.getTargetBlock().getZ() + y - brushSize).getType() == Material.SNOW) && ((this.clampY(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize - 1, this.getTargetBlock().getZ() + y - brushSize).getType() == Material.SNOW) || (this.clampY(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize - 1, this.getTargetBlock().getZ() + y - brushSize).isEmpty()))) {
{
if ((this.clampY(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, this.getTargetBlock().getZ() + y - brushSize).getType() == Material.SNOW) && ((this.clampY(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize - 1, this.getTargetBlock().getZ() + y - brushSize).getType() == Material.SNOW) || (this.clampY(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize - 1, this.getTargetBlock().getZ() + y - brushSize).isEmpty())))
{
undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + z, this.getTargetBlock().getZ() + y)); undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + z, this.getTargetBlock().getZ() + y));
this.setBlockIdAt(this.getTargetBlock().getZ() + y - brushSize, this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, BlockTypes.AIR.getInternalId()); this.setBlockIdAt(this.getTargetBlock().getZ() + y - brushSize, this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, BlockTypes.AIR.getInternalId());
} }
@ -58,57 +49,44 @@ public class CleanSnowBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.cleanSnow(v); this.cleanSnow(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.cleanSnow(v); this.cleanSnow(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Clean Snow Brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Clean Snow Brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b cls true -- will use a true sphere algorithm instead of the skinnier version with classic sniper nubs. /b cls false will switch back. (false is default)"); v.sendMessage(ChatColor.AQUA + "/b cls true -- will use a true sphere algorithm instead of the skinnier version with classic sniper nubs. /b cls false will switch back. (false is default)");
return; return;
} } else if (parameter.startsWith("true")) {
else if (parameter.startsWith("true"))
{
this.trueCircle = 0.5; this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON."); v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
} } else if (parameter.startsWith("false")) {
else if (parameter.startsWith("false"))
{
this.trueCircle = 0; this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.cleansnow"; return "voxelsniper.brush.cleansnow";
} }
} }

Datei anzeigen

@ -2,7 +2,6 @@ package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
/** /**
@ -11,13 +10,11 @@ import org.bukkit.ChatColor;
* *
* @author Voxel * @author Voxel
*/ */
public class CloneStampBrush extends StampBrush public class CloneStampBrush extends StampBrush {
{
/** /**
* *
*/ */
public CloneStampBrush() public CloneStampBrush() {
{
this.setName("Clone"); this.setName("Clone");
} }
@ -27,11 +24,9 @@ public class CloneStampBrush extends StampBrush
* x y z -- initial center of the selection v.brushSize -- the radius of the cylinder v.voxelHeight -- the heigth of the cylinder c.cCen -- the offset on * x y z -- initial center of the selection v.brushSize -- the radius of the cylinder v.voxelHeight -- the heigth of the cylinder c.cCen -- the offset on
* the Y axis of the selection ( bottom of the cylinder ) as blockPositionY: Bottom_Y = targetBlock.y + v.cCen; * the Y axis of the selection ( bottom of the cylinder ) as blockPositionY: Bottom_Y = targetBlock.y + v.cCen;
* *
* @param v * @param v the caller
* the caller
*/ */
private void clone(final SnipeData v) private void clone(final SnipeData v) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
this.clone.clear(); this.clone.clear();
this.fall.clear(); this.fall.clear();
@ -42,47 +37,36 @@ public class CloneStampBrush extends StampBrush
int yStartingPoint = this.getTargetBlock().getY() + v.getcCen(); int yStartingPoint = this.getTargetBlock().getY() + v.getcCen();
int yEndPoint = this.getTargetBlock().getY() + v.getVoxelHeight() + v.getcCen(); int yEndPoint = this.getTargetBlock().getY() + v.getVoxelHeight() + v.getcCen();
if (yStartingPoint < 0) if (yStartingPoint < 0) {
{
yStartingPoint = 0; yStartingPoint = 0;
v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position."); v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position.");
} } else if (yStartingPoint > this.getWorld().getMaxHeight() - 1) {
else if (yStartingPoint > this.getWorld().getMaxHeight() - 1)
{
yStartingPoint = this.getWorld().getMaxHeight() - 1; yStartingPoint = this.getWorld().getMaxHeight() - 1;
v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position."); v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position.");
} }
if (yEndPoint < 0) if (yEndPoint < 0) {
{
yEndPoint = 0; yEndPoint = 0;
v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position."); v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position.");
} } else if (yEndPoint > this.getWorld().getMaxHeight() - 1) {
else if (yEndPoint > this.getWorld().getMaxHeight() - 1)
{
yEndPoint = this.getWorld().getMaxHeight() - 1; yEndPoint = this.getWorld().getMaxHeight() - 1;
v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position."); v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position.");
} }
final double bSquared = Math.pow(brushSize, 2); final double bSquared = Math.pow(brushSize, 2);
for (int z = yStartingPoint; z < yEndPoint; z++) for (int z = yStartingPoint; z < yEndPoint; z++) {
{
this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX(), z, this.getTargetBlock().getZ()), 0, z - yStartingPoint, 0)); this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX(), z, this.getTargetBlock().getZ()), 0, z - yStartingPoint, 0));
for (int y = 1; y <= brushSize; y++) for (int y = 1; y <= brushSize; y++) {
{
this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX(), z, this.getTargetBlock().getZ() + y), 0, z - yStartingPoint, y)); this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX(), z, this.getTargetBlock().getZ() + y), 0, z - yStartingPoint, y));
this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX(), z, this.getTargetBlock().getZ() - y), 0, z - yStartingPoint, -y)); this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX(), z, this.getTargetBlock().getZ() - y), 0, z - yStartingPoint, -y));
this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() + y, z, this.getTargetBlock().getZ()), y, z - yStartingPoint, 0)); this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() + y, z, this.getTargetBlock().getZ()), y, z - yStartingPoint, 0));
this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() - y, z, this.getTargetBlock().getZ()), -y, z - yStartingPoint, 0)); this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() - y, z, this.getTargetBlock().getZ()), -y, z - yStartingPoint, 0));
} }
for (int x = 1; x <= brushSize; x++) for (int x = 1; x <= brushSize; x++) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int y = 1; y <= brushSize; y++) for (int y = 1; y <= brushSize; y++) {
{ if ((xSquared + Math.pow(y, 2)) <= bSquared) {
if ((xSquared + Math.pow(y, 2)) <= bSquared)
{
this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() + x, z, this.getTargetBlock().getZ() + y), x, z - yStartingPoint, y)); this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() + x, z, this.getTargetBlock().getZ() + y), x, z - yStartingPoint, y));
this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() + x, z, this.getTargetBlock().getZ() - y), x, z - yStartingPoint, -y)); this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() + x, z, this.getTargetBlock().getZ() - y), x, z - yStartingPoint, -y));
this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() - x, z, this.getTargetBlock().getZ() + y), -x, z - yStartingPoint, y)); this.clone.add(new BlockWrapper(this.clampY(this.getTargetBlock().getX() - x, z, this.getTargetBlock().getZ() + y), -x, z - yStartingPoint, y));
@ -95,20 +79,17 @@ public class CloneStampBrush extends StampBrush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.clone(v); this.clone(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.height(); vm.height();
vm.center(); vm.center();
switch (this.stamp) switch (this.stamp) {
{
case DEFAULT: case DEFAULT:
vm.brushMessage("Default Stamp"); vm.brushMessage("Default Stamp");
break; break;
@ -128,45 +109,35 @@ public class CloneStampBrush extends StampBrush
} }
@Override @Override
public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) {
{
final String parameter = par[1]; final String parameter = par[1];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Clone / Stamp Cylinder brush parameters"); v.sendMessage(ChatColor.GOLD + "Clone / Stamp Cylinder brush parameters");
v.sendMessage(ChatColor.GREEN + "cs f -- Activates Fill mode"); v.sendMessage(ChatColor.GREEN + "cs f -- Activates Fill mode");
v.sendMessage(ChatColor.GREEN + "cs a -- Activates No-Air mode"); v.sendMessage(ChatColor.GREEN + "cs a -- Activates No-Air mode");
v.sendMessage(ChatColor.GREEN + "cs d -- Activates Default mode"); v.sendMessage(ChatColor.GREEN + "cs d -- Activates Default mode");
} }
if (parameter.equalsIgnoreCase("a")) if (parameter.equalsIgnoreCase("a")) {
{
this.setStamp(StampType.NO_AIR); this.setStamp(StampType.NO_AIR);
this.reSort(); this.reSort();
v.sendMessage(ChatColor.AQUA + "No-Air stamp brush"); v.sendMessage(ChatColor.AQUA + "No-Air stamp brush");
} } else if (parameter.equalsIgnoreCase("f")) {
else if (parameter.equalsIgnoreCase("f"))
{
this.setStamp(StampType.FILL); this.setStamp(StampType.FILL);
this.reSort(); this.reSort();
v.sendMessage(ChatColor.AQUA + "Fill stamp brush"); v.sendMessage(ChatColor.AQUA + "Fill stamp brush");
} } else if (parameter.equalsIgnoreCase("d")) {
else if (parameter.equalsIgnoreCase("d"))
{
this.setStamp(StampType.DEFAULT); this.setStamp(StampType.DEFAULT);
this.reSort(); this.reSort();
v.sendMessage(ChatColor.AQUA + "Default stamp brush"); v.sendMessage(ChatColor.AQUA + "Default stamp brush");
} } else if (parameter.startsWith("c")) {
else if (parameter.startsWith("c"))
{
v.setcCen(Integer.parseInt(parameter.replace("c", ""))); v.setcCen(Integer.parseInt(parameter.replace("c", "")));
v.sendMessage(ChatColor.BLUE + "Center set to " + v.getcCen()); v.sendMessage(ChatColor.BLUE + "Center set to " + v.getcCen());
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.clonestamp"; return "voxelsniper.brush.clonestamp";
} }
} }

Datei anzeigen

@ -1,79 +1,62 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.LargeFireball; import org.bukkit.entity.LargeFireball;
import org.bukkit.entity.SmallFireball; import org.bukkit.entity.SmallFireball;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
/** /**
* @author Gavjenks Heavily revamped from ruler brush blockPositionY * @author Gavjenks Heavily revamped from ruler brush blockPositionY
* @author Giltwist * @author Giltwist
* @author Monofraps (Merged Meteor brush) * @author Monofraps (Merged Meteor brush)
*/ */
public class CometBrush extends Brush public class CometBrush extends Brush {
{
private boolean useBigBalls = false; private boolean useBigBalls = false;
/** /**
* *
*/ */
public CometBrush() public CometBrush() {
{
this.setName("Comet"); this.setName("Comet");
} }
private void doFireball(final SnipeData v) private void doFireball(final SnipeData v) {
{
final Vector targetCoords = new Vector(this.getTargetBlock().getX() + .5 * this.getTargetBlock().getX() / Math.abs(this.getTargetBlock().getX()), this.getTargetBlock().getY() + .5, this.getTargetBlock().getZ() + .5 * this.getTargetBlock().getZ() / Math.abs(this.getTargetBlock().getZ())); final Vector targetCoords = new Vector(this.getTargetBlock().getX() + .5 * this.getTargetBlock().getX() / Math.abs(this.getTargetBlock().getX()), this.getTargetBlock().getY() + .5, this.getTargetBlock().getZ() + .5 * this.getTargetBlock().getZ() / Math.abs(this.getTargetBlock().getZ()));
final Location playerLocation = v.owner().getPlayer().getEyeLocation(); final Location playerLocation = v.owner().getPlayer().getEyeLocation();
final Vector slope = targetCoords.subtract(playerLocation.toVector()); final Vector slope = targetCoords.subtract(playerLocation.toVector());
if (useBigBalls) if (useBigBalls) {
{
v.owner().getPlayer().launchProjectile(LargeFireball.class).setVelocity(slope.normalize()); v.owner().getPlayer().launchProjectile(LargeFireball.class).setVelocity(slope.normalize());
} } else {
else
{
v.owner().getPlayer().launchProjectile(SmallFireball.class).setVelocity(slope.normalize()); v.owner().getPlayer().launchProjectile(SmallFireball.class).setVelocity(slope.normalize());
} }
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 0; i < par.length; ++i) {
for (int i = 0; i < par.length; ++i)
{
String parameter = par[i]; String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage("Parameters:"); v.sendMessage("Parameters:");
v.sendMessage("balls [big|small] -- Sets your ball size."); v.sendMessage("balls [big|small] -- Sets your ball size.");
} }
if (parameter.equalsIgnoreCase("balls")) if (parameter.equalsIgnoreCase("balls")) {
{ if (i + 1 >= par.length) {
if (i + 1 >= par.length)
{
v.sendMessage("The balls parameter expects a ball size after it."); v.sendMessage("The balls parameter expects a ball size after it.");
} }
String newBallSize = par[++i]; String newBallSize = par[++i];
if (newBallSize.equalsIgnoreCase("big")) if (newBallSize.equalsIgnoreCase("big")) {
{
useBigBalls = true; useBigBalls = true;
v.sendMessage("Your balls are " + ChatColor.DARK_RED + ("BIG")); v.sendMessage("Your balls are " + ChatColor.DARK_RED + ("BIG"));
} } else if (newBallSize.equalsIgnoreCase("small")) {
else if (newBallSize.equalsIgnoreCase("small"))
{
useBigBalls = false; useBigBalls = false;
v.sendMessage("Your balls are " + ChatColor.DARK_RED + ("small")); v.sendMessage("Your balls are " + ChatColor.DARK_RED + ("small"));
} } else {
else
{
v.sendMessage("Unknown ball size."); v.sendMessage("Unknown ball size.");
} }
} }
@ -81,28 +64,24 @@ public class CometBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.doFireball(v); this.doFireball(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.doFireball(v); this.doFireball(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.voxel(); vm.voxel();
vm.custom("Your balls are " + ChatColor.DARK_RED + (useBigBalls ? "BIG" : "small")); vm.custom("Your balls are " + ChatColor.DARK_RED + (useBigBalls ? "BIG" : "small"));
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.comet"; return "voxelsniper.brush.comet";
} }
} }

Datei anzeigen

@ -5,17 +5,14 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#CopyPasta_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#CopyPasta_Brush
* *
* @author giltwist * @author giltwist
*/ */
public class CopyPastaBrush extends Brush public class CopyPastaBrush extends Brush {
{
private static final int BLOCK_LIMIT = 10000; private static final int BLOCK_LIMIT = 10000;
private boolean pasteAir = true; // False = no air, true = air private boolean pasteAir = true; // False = no air, true = air
@ -33,16 +30,13 @@ public class CopyPastaBrush extends Brush
/** /**
* *
*/ */
public CopyPastaBrush() public CopyPastaBrush() {
{
this.setName("CopyPasta"); this.setName("CopyPasta");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void doCopy(final SnipeData v) private void doCopy(final SnipeData v) {
{ for (int i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++)
{
this.arraySize[i] = Math.abs(this.firstPoint[i] - this.secondPoint[i]) + 1; this.arraySize[i] = Math.abs(this.firstPoint[i] - this.secondPoint[i]) + 1;
this.minPoint[i] = Math.min(this.firstPoint[i], this.secondPoint[i]); this.minPoint[i] = Math.min(this.firstPoint[i], this.secondPoint[i]);
this.offsetPoint[i] = this.minPoint[i] - this.firstPoint[i]; // will always be negative or zero this.offsetPoint[i] = this.minPoint[i] - this.firstPoint[i]; // will always be negative or zero
@ -50,16 +44,12 @@ public class CopyPastaBrush extends Brush
this.numBlocks = (this.arraySize[0]) * (this.arraySize[1]) * (this.arraySize[2]); this.numBlocks = (this.arraySize[0]) * (this.arraySize[1]) * (this.arraySize[2]);
if (this.numBlocks > 0 && this.numBlocks < CopyPastaBrush.BLOCK_LIMIT) if (this.numBlocks > 0 && this.numBlocks < CopyPastaBrush.BLOCK_LIMIT) {
{
this.blockArray = new int[this.numBlocks]; this.blockArray = new int[this.numBlocks];
for (int i = 0; i < this.arraySize[0]; i++) for (int i = 0; i < this.arraySize[0]; i++) {
{ for (int j = 0; j < this.arraySize[1]; j++) {
for (int j = 0; j < this.arraySize[1]; j++) for (int k = 0; k < this.arraySize[2]; k++) {
{
for (int k = 0; k < this.arraySize[2]; k++)
{
final int currentPosition = i + this.arraySize[0] * j + this.arraySize[0] * this.arraySize[1] * k; final int currentPosition = i + this.arraySize[0] * j + this.arraySize[0] * this.arraySize[1] * k;
this.blockArray[currentPosition] = this.getWorld().getBlockAt(this.minPoint[0] + i, this.minPoint[1] + j, this.minPoint[2] + k).getCombinedId(); this.blockArray[currentPosition] = this.getWorld().getBlockAt(this.minPoint[0] + i, this.minPoint[1] + j, this.minPoint[2] + k).getCombinedId();
} }
@ -67,29 +57,22 @@ public class CopyPastaBrush extends Brush
} }
v.sendMessage(ChatColor.AQUA + "" + this.numBlocks + " blocks copied."); v.sendMessage(ChatColor.AQUA + "" + this.numBlocks + " blocks copied.");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Copy area too big: " + this.numBlocks + "(Limit: " + CopyPastaBrush.BLOCK_LIMIT + ")"); v.sendMessage(ChatColor.RED + "Copy area too big: " + this.numBlocks + "(Limit: " + CopyPastaBrush.BLOCK_LIMIT + ")");
} }
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void doPasta(final SnipeData v) private void doPasta(final SnipeData v) {
{
final Undo undo = new Undo(); final Undo undo = new Undo();
for (int i = 0; i < this.arraySize[0]; i++) for (int i = 0; i < this.arraySize[0]; i++) {
{ for (int j = 0; j < this.arraySize[1]; j++) {
for (int j = 0; j < this.arraySize[1]; j++) for (int k = 0; k < this.arraySize[2]; k++) {
{
for (int k = 0; k < this.arraySize[2]; k++)
{
final int currentPosition = i + this.arraySize[0] * j + this.arraySize[0] * this.arraySize[1] * k; final int currentPosition = i + this.arraySize[0] * j + this.arraySize[0] * this.arraySize[1] * k;
AsyncBlock block; AsyncBlock block;
switch (this.pivot) switch (this.pivot) {
{
case 180: case 180:
block = this.clampY(this.pastePoint[0] - this.offsetPoint[0] - i, this.pastePoint[1] + this.offsetPoint[1] + j, this.pastePoint[2] - this.offsetPoint[2] - k); block = this.clampY(this.pastePoint[0] - this.offsetPoint[0] - i, this.pastePoint[1] + this.offsetPoint[1] + j, this.pastePoint[2] - this.offsetPoint[2] - k);
break; break;
@ -104,11 +87,9 @@ public class CopyPastaBrush extends Brush
break; break;
} }
if (!(BlockTypes.getFromStateId(this.blockArray[currentPosition]).getMaterial().isAir() && !this.pasteAir)) if (!(BlockTypes.getFromStateId(this.blockArray[currentPosition]).getMaterial().isAir() && !this.pasteAir)) {
{
if (block.getCombinedId() != this.blockArray[currentPosition]) if (block.getCombinedId() != this.blockArray[currentPosition]) {
{
undo.put(block); undo.put(block);
} }
block.setCombinedId(this.blockArray[currentPosition]); block.setCombinedId(this.blockArray[currentPosition]);
@ -122,10 +103,8 @@ public class CopyPastaBrush extends Brush
} }
@Override @Override
protected final void arrow(final com.thevoxelbox.voxelsniper.SnipeData v) protected final void arrow(final com.thevoxelbox.voxelsniper.SnipeData v) {
{ switch (this.points) {
switch (this.points)
{
case 0: case 0:
this.firstPoint[0] = this.getTargetBlock().getX(); this.firstPoint[0] = this.getTargetBlock().getX();
this.firstPoint[1] = this.getTargetBlock().getY(); this.firstPoint[1] = this.getTargetBlock().getY();
@ -152,71 +131,56 @@ public class CopyPastaBrush extends Brush
} }
@Override @Override
protected final void powder(final com.thevoxelbox.voxelsniper.SnipeData v) protected final void powder(final com.thevoxelbox.voxelsniper.SnipeData v) {
{ if (this.points == 2) {
if (this.points == 2) if (this.numBlocks == 0) {
{
if (this.numBlocks == 0)
{
this.doCopy(v); this.doCopy(v);
} } else if (this.numBlocks > 0 && this.numBlocks < CopyPastaBrush.BLOCK_LIMIT) {
else if (this.numBlocks > 0 && this.numBlocks < CopyPastaBrush.BLOCK_LIMIT)
{
this.pastePoint[0] = this.getTargetBlock().getX(); this.pastePoint[0] = this.getTargetBlock().getX();
this.pastePoint[1] = this.getTargetBlock().getY(); this.pastePoint[1] = this.getTargetBlock().getY();
this.pastePoint[2] = this.getTargetBlock().getZ(); this.pastePoint[2] = this.getTargetBlock().getZ();
this.doPasta(v); this.doPasta(v);
} } else {
else
{
v.sendMessage(ChatColor.RED + "Error"); v.sendMessage(ChatColor.RED + "Error");
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "You must select exactly two points."); v.sendMessage(ChatColor.RED + "You must select exactly two points.");
} }
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.GOLD + "Paste air: " + this.pasteAir); vm.custom(ChatColor.GOLD + "Paste air: " + this.pasteAir);
vm.custom(ChatColor.GOLD + "Pivot angle: " + this.pivot); vm.custom(ChatColor.GOLD + "Pivot angle: " + this.pivot);
} }
@Override @Override
public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) {
{
final String parameter = par[1]; final String parameter = par[1];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "CopyPasta Parameters:"); v.sendMessage(ChatColor.GOLD + "CopyPasta Parameters:");
v.sendMessage(ChatColor.AQUA + "/b cp air -- toggle include (default) or exclude air during paste"); v.sendMessage(ChatColor.AQUA + "/b cp air -- toggle include (default) or exclude air during paste");
v.sendMessage(ChatColor.AQUA + "/b cp 0|90|180|270 -- toggle rotation (0 default)"); v.sendMessage(ChatColor.AQUA + "/b cp 0|90|180|270 -- toggle rotation (0 default)");
return; return;
} }
if (parameter.equalsIgnoreCase("air")) if (parameter.equalsIgnoreCase("air")) {
{
this.pasteAir = !this.pasteAir; this.pasteAir = !this.pasteAir;
v.sendMessage(ChatColor.GOLD + "Paste air: " + this.pasteAir); v.sendMessage(ChatColor.GOLD + "Paste air: " + this.pasteAir);
return; return;
} }
if (parameter.equalsIgnoreCase("90") || parameter.equalsIgnoreCase("180") || parameter.equalsIgnoreCase("270") || parameter.equalsIgnoreCase("0")) if (parameter.equalsIgnoreCase("90") || parameter.equalsIgnoreCase("180") || parameter.equalsIgnoreCase("270") || parameter.equalsIgnoreCase("0")) {
{
this.pivot = Integer.parseInt(parameter); this.pivot = Integer.parseInt(parameter);
v.sendMessage(ChatColor.GOLD + "Pivot angle: " + this.pivot); v.sendMessage(ChatColor.GOLD + "Pivot angle: " + this.pivot);
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.copypasta"; return "voxelsniper.brush.copypasta";
} }
} }

Datei anzeigen

@ -9,61 +9,47 @@ import org.bukkit.block.Block;
/** /**
* @author Kavutop * @author Kavutop
*/ */
public class CylinderBrush extends PerformBrush public class CylinderBrush extends PerformBrush {
{
private double trueCircle = 0; private double trueCircle = 0;
/** /**
* *
*/ */
public CylinderBrush() public CylinderBrush() {
{
this.setName("Cylinder"); this.setName("Cylinder");
} }
private void cylinder(final SnipeData v, Block targetBlock) private void cylinder(final SnipeData v, Block targetBlock) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
int yStartingPoint = targetBlock.getY() + v.getcCen(); int yStartingPoint = targetBlock.getY() + v.getcCen();
int yEndPoint = targetBlock.getY() + v.getVoxelHeight() + v.getcCen(); int yEndPoint = targetBlock.getY() + v.getVoxelHeight() + v.getcCen();
if (yEndPoint < yStartingPoint) if (yEndPoint < yStartingPoint) {
{
yEndPoint = yStartingPoint; yEndPoint = yStartingPoint;
} }
if (yStartingPoint < 0) if (yStartingPoint < 0) {
{
yStartingPoint = 0; yStartingPoint = 0;
v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position."); v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position.");
} } else if (yStartingPoint > this.getWorld().getMaxHeight() - 1) {
else if (yStartingPoint > this.getWorld().getMaxHeight() - 1)
{
yStartingPoint = this.getWorld().getMaxHeight() - 1; yStartingPoint = this.getWorld().getMaxHeight() - 1;
v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position."); v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position.");
} }
if (yEndPoint < 0) if (yEndPoint < 0) {
{
yEndPoint = 0; yEndPoint = 0;
v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position."); v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position.");
} } else if (yEndPoint > this.getWorld().getMaxHeight() - 1) {
else if (yEndPoint > this.getWorld().getMaxHeight() - 1)
{
yEndPoint = this.getWorld().getMaxHeight() - 1; yEndPoint = this.getWorld().getMaxHeight() - 1;
v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position."); v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position.");
} }
final double bSquared = Math.pow(brushSize + this.trueCircle, 2); final double bSquared = Math.pow(brushSize + this.trueCircle, 2);
for (int y = yEndPoint; y >= yStartingPoint; y--) for (int y = yEndPoint; y >= yStartingPoint; y--) {
{ for (int x = brushSize; x >= 0; x--) {
for (int x = brushSize; x >= 0; x--)
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int z = brushSize; z >= 0; z--) for (int z = brushSize; z >= 0; z--) {
{ if ((xSquared + Math.pow(z, 2)) <= bSquared) {
if ((xSquared + Math.pow(z, 2)) <= bSquared)
{
this.current.perform(this.clampY(targetBlock.getX() + x, y, targetBlock.getZ() + z)); this.current.perform(this.clampY(targetBlock.getX() + x, y, targetBlock.getZ() + z));
this.current.perform(this.clampY(targetBlock.getX() + x, y, targetBlock.getZ() - z)); this.current.perform(this.clampY(targetBlock.getX() + x, y, targetBlock.getZ() - z));
this.current.perform(this.clampY(targetBlock.getX() - x, y, targetBlock.getZ() + z)); this.current.perform(this.clampY(targetBlock.getX() - x, y, targetBlock.getZ() + z));
@ -76,20 +62,17 @@ public class CylinderBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.cylinder(v, this.getTargetBlock()); this.cylinder(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.cylinder(v, this.getLastBlock()); this.cylinder(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.height(); vm.height();
@ -97,50 +80,37 @@ public class CylinderBrush extends PerformBrush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Cylinder Brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Cylinder Brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b c h[number] -- set the cylinder v.voxelHeight. Default is 1."); v.sendMessage(ChatColor.AQUA + "/b c h[number] -- set the cylinder v.voxelHeight. Default is 1.");
v.sendMessage(ChatColor.DARK_AQUA + "/b c true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b b false will switch back. (false is default)"); v.sendMessage(ChatColor.DARK_AQUA + "/b c true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b b false will switch back. (false is default)");
v.sendMessage(ChatColor.DARK_BLUE + "/b c c[number] -- set the origin of the cylinder compared to the target block. Positive numbers will move the cylinder upward, negative will move it downward."); v.sendMessage(ChatColor.DARK_BLUE + "/b c c[number] -- set the origin of the cylinder compared to the target block. Positive numbers will move the cylinder upward, negative will move it downward.");
return; return;
} }
if (parameter.startsWith("true")) if (parameter.startsWith("true")) {
{
this.trueCircle = 0.5; this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON."); v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
} } else if (parameter.startsWith("false")) {
else if (parameter.startsWith("false"))
{
this.trueCircle = 0; this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} } else if (parameter.startsWith("h")) {
else if (parameter.startsWith("h"))
{
v.setVoxelHeight((int) Double.parseDouble(parameter.replace("h", ""))); v.setVoxelHeight((int) Double.parseDouble(parameter.replace("h", "")));
v.sendMessage(ChatColor.AQUA + "Cylinder v.voxelHeight set to: " + v.getVoxelHeight()); v.sendMessage(ChatColor.AQUA + "Cylinder v.voxelHeight set to: " + v.getVoxelHeight());
} } else if (parameter.startsWith("c")) {
else if (parameter.startsWith("c"))
{
v.setcCen((int) Double.parseDouble(parameter.replace("c", ""))); v.setcCen((int) Double.parseDouble(parameter.replace("c", "")));
v.sendMessage(ChatColor.AQUA + "Cylinder origin set to: " + v.getcCen()); v.sendMessage(ChatColor.AQUA + "Cylinder origin set to: " + v.getcCen());
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.cylinder"; return "voxelsniper.brush.cylinder";
} }
} }

Datei anzeigen

@ -3,7 +3,6 @@ package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -13,15 +12,13 @@ import org.bukkit.util.Vector;
* *
* @author Voxel * @author Voxel
*/ */
public class DiscBrush extends PerformBrush public class DiscBrush extends PerformBrush {
{
private double trueCircle = 0; private double trueCircle = 0;
/** /**
* Default Constructor. * Default Constructor.
*/ */
public DiscBrush() public DiscBrush() {
{
this.setName("Disc"); this.setName("Disc");
} }
@ -30,20 +27,16 @@ public class DiscBrush extends PerformBrush
* *
* @param v * @param v
*/ */
private void disc(final SnipeData v, final Block targetBlock) private void disc(final SnipeData v, final Block targetBlock) {
{
final double radiusSquared = (v.getBrushSize() + this.trueCircle) * (v.getBrushSize() + this.trueCircle); final double radiusSquared = (v.getBrushSize() + this.trueCircle) * (v.getBrushSize() + this.trueCircle);
final Vector centerPoint = targetBlock.getLocation().toVector(); final Vector centerPoint = targetBlock.getLocation().toVector();
final Vector currentPoint = centerPoint.clone(); final Vector currentPoint = centerPoint.clone();
for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) {
{
currentPoint.setX(centerPoint.getX() + x); currentPoint.setX(centerPoint.getX() + x);
for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) {
{
currentPoint.setZ(centerPoint.getZ() + z); currentPoint.setZ(centerPoint.getZ() + z);
if (centerPoint.distanceSquared(currentPoint) <= radiusSquared) if (centerPoint.distanceSquared(currentPoint) <= radiusSquared) {
{
this.current.perform(this.clampY(currentPoint.getBlockX(), currentPoint.getBlockY(), currentPoint.getBlockZ())); this.current.perform(this.clampY(currentPoint.getBlockX(), currentPoint.getBlockY(), currentPoint.getBlockZ()));
} }
} }
@ -52,57 +45,44 @@ public class DiscBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.disc(v, this.getTargetBlock()); this.disc(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.disc(v, this.getLastBlock()); this.disc(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i].toLowerCase(); final String parameter = par[i].toLowerCase();
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Disc Brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Disc Brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b d true|false" + " -- toggles useing the true circle algorithm instead of the skinnier version with classic sniper nubs. (false is default)"); v.sendMessage(ChatColor.AQUA + "/b d true|false" + " -- toggles useing the true circle algorithm instead of the skinnier version with classic sniper nubs. (false is default)");
return; return;
} } else if (parameter.startsWith("true")) {
else if (parameter.startsWith("true"))
{
this.trueCircle = 0.5; this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON."); v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
} } else if (parameter.startsWith("false")) {
else if (parameter.startsWith("false"))
{
this.trueCircle = 0; this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.disc"; return "voxelsniper.brush.disc";
} }
} }

Datei anzeigen

@ -5,7 +5,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
/** /**
@ -13,31 +12,25 @@ import org.bukkit.block.BlockFace;
* *
* @author Voxel * @author Voxel
*/ */
public class DiscFaceBrush extends PerformBrush public class DiscFaceBrush extends PerformBrush {
{
private double trueCircle = 0; private double trueCircle = 0;
/** /**
* *
*/ */
public DiscFaceBrush() public DiscFaceBrush() {
{
this.setName("Disc Face"); this.setName("Disc Face");
} }
private void discUD(final SnipeData v, AsyncBlock targetBlock) private void discUD(final SnipeData v, AsyncBlock targetBlock) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
for (int x = brushSize; x >= 0; x--) for (int x = brushSize; x >= 0; x--) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int z = brushSize; z >= 0; z--) for (int z = brushSize; z >= 0; z--) {
{ if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared) {
if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared)
{
current.perform(targetBlock.getRelative(x, 0, z)); current.perform(targetBlock.getRelative(x, 0, z));
current.perform(targetBlock.getRelative(x, 0, -z)); current.perform(targetBlock.getRelative(x, 0, -z));
current.perform(targetBlock.getRelative(-x, 0, z)); current.perform(targetBlock.getRelative(-x, 0, z));
@ -49,18 +42,14 @@ public class DiscFaceBrush extends PerformBrush
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void discNS(final SnipeData v, AsyncBlock targetBlock) private void discNS(final SnipeData v, AsyncBlock targetBlock) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
for (int x = brushSize; x >= 0; x--) for (int x = brushSize; x >= 0; x--) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int y = brushSize; y >= 0; y--) for (int y = brushSize; y >= 0; y--) {
{ if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared) {
if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared)
{
current.perform(targetBlock.getRelative(x, y, 0)); current.perform(targetBlock.getRelative(x, y, 0));
current.perform(targetBlock.getRelative(x, -y, 0)); current.perform(targetBlock.getRelative(x, -y, 0));
current.perform(targetBlock.getRelative(-x, y, 0)); current.perform(targetBlock.getRelative(-x, y, 0));
@ -72,18 +61,14 @@ public class DiscFaceBrush extends PerformBrush
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void discEW(final SnipeData v, AsyncBlock targetBlock) private void discEW(final SnipeData v, AsyncBlock targetBlock) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
for (int x = brushSize; x >= 0; x--) for (int x = brushSize; x >= 0; x--) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int y = brushSize; y >= 0; y--) for (int y = brushSize; y >= 0; y--) {
{ if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared) {
if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared)
{
current.perform(targetBlock.getRelative(0, x, y)); current.perform(targetBlock.getRelative(0, x, y));
current.perform(targetBlock.getRelative(0, x, -y)); current.perform(targetBlock.getRelative(0, x, -y));
current.perform(targetBlock.getRelative(0, -x, y)); current.perform(targetBlock.getRelative(0, -x, y));
@ -95,15 +80,12 @@ public class DiscFaceBrush extends PerformBrush
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void pre(final SnipeData v, AsyncBlock targetBlock) private void pre(final SnipeData v, AsyncBlock targetBlock) {
{
BlockFace blockFace = getTargetBlock().getFace(this.getLastBlock()); BlockFace blockFace = getTargetBlock().getFace(this.getLastBlock());
if (blockFace == null) if (blockFace == null) {
{
return; return;
} }
switch (blockFace) switch (blockFace) {
{
case NORTH: case NORTH:
case SOUTH: case SOUTH:
this.discNS(v, targetBlock); this.discNS(v, targetBlock);
@ -125,57 +107,45 @@ public class DiscFaceBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.pre(v, this.getTargetBlock()); this.pre(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.pre(v, this.getLastBlock()); this.pre(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Disc Face brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Disc Face brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b df true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b b false will switch back. (false is default)"); v.sendMessage(ChatColor.AQUA + "/b df true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b b false will switch back. (false is default)");
return; return;
} }
if (parameter.startsWith("true")) if (parameter.startsWith("true")) {
{
this.trueCircle = 0.5; this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON."); v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
} } else if (parameter.startsWith("false")) {
else if (parameter.startsWith("false"))
{
this.trueCircle = 0; this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.discface"; return "voxelsniper.brush.discface";
} }
} }

Datei anzeigen

@ -1,36 +1,32 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import java.util.HashSet;
import java.util.Set;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.Set;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Dome_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#Dome_Brush
* *
* @author Gavjenks * @author Gavjenks
* @author MikeMatrix * @author MikeMatrix
*/ */
public class DomeBrush extends Brush public class DomeBrush extends Brush {
{
/** /**
* *
*/ */
public DomeBrush() public DomeBrush() {
{
this.setName("Dome"); this.setName("Dome");
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.voxel(); vm.voxel();
@ -42,11 +38,9 @@ public class DomeBrush extends Brush
* @param targetBlock * @param targetBlock
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void generateDome(final SnipeData v, final Block targetBlock) private void generateDome(final SnipeData v, final Block targetBlock) {
{
if (v.getVoxelHeight() == 0) if (v.getVoxelHeight() == 0) {
{
v.sendMessage("VoxelHeight must not be 0."); v.sendMessage("VoxelHeight must not be 0.");
return; return;
} }
@ -63,11 +57,9 @@ public class DomeBrush extends Brush
final double stepSize = 1 / stepScale; final double stepSize = 1 / stepScale;
for (double u = 0; u <= Math.PI / 2; u += stepSize) for (double u = 0; u <= Math.PI / 2; u += stepSize) {
{
final double y = absoluteHeight * Math.sin(u); final double y = absoluteHeight * Math.sin(u);
for (double stepV = -Math.PI; stepV <= -(Math.PI / 2); stepV += stepSize) for (double stepV = -Math.PI; stepV <= -(Math.PI / 2); stepV += stepSize) {
{
final double x = v.getBrushSize() * Math.cos(u) * Math.cos(stepV); final double x = v.getBrushSize() * Math.cos(u) * Math.cos(stepV);
final double z = v.getBrushSize() * Math.cos(u) * Math.sin(stepV); final double z = v.getBrushSize() * Math.cos(u) * Math.sin(stepV);
@ -86,11 +78,9 @@ public class DomeBrush extends Brush
} }
} }
for (final Vector vector : changeablePositions) for (final Vector vector : changeablePositions) {
{
final AsyncBlock currentTargetBlock = (AsyncBlock) vector.toLocation(this.getTargetBlock().getWorld()).getBlock(); final AsyncBlock currentTargetBlock = (AsyncBlock) vector.toLocation(this.getTargetBlock().getWorld()).getBlock();
if (currentTargetBlock.getTypeId() != v.getVoxelId() || currentTargetBlock.getPropertyId() != v.getPropertyId()) if (currentTargetBlock.getTypeId() != v.getVoxelId() || currentTargetBlock.getPropertyId() != v.getPropertyId()) {
{
undo.put(currentTargetBlock); undo.put(currentTargetBlock);
currentTargetBlock.setTypeIdAndPropertyId(v.getVoxelId(), v.getPropertyId(), true); currentTargetBlock.setTypeIdAndPropertyId(v.getVoxelId(), v.getPropertyId(), true);
} }
@ -100,20 +90,17 @@ public class DomeBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.generateDome(v, this.getTargetBlock()); this.generateDome(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.generateDome(v, this.getLastBlock()); this.generateDome(v, this.getLastBlock());
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.dome"; return "voxelsniper.brush.dome";
} }
} }

Datei anzeigen

@ -4,9 +4,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#The_Drain_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Drain_Brush
@ -14,79 +12,61 @@ import org.bukkit.Material;
* @author Gavjenks * @author Gavjenks
* @author psanker * @author psanker
*/ */
public class DrainBrush extends Brush public class DrainBrush extends Brush {
{
private double trueCircle = 0; private double trueCircle = 0;
private boolean disc = false; private boolean disc = false;
/** /**
* *
*/ */
public DrainBrush() public DrainBrush() {
{
this.setName("Drain"); this.setName("Drain");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void drain(final SnipeData v) private void drain(final SnipeData v) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
final Undo undo = new Undo(); final Undo undo = new Undo();
if (this.disc) if (this.disc) {
{ for (int x = brushSize; x >= 0; x--) {
for (int x = brushSize; x >= 0; x--)
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int y = brushSize; y >= 0; y--) for (int y = brushSize; y >= 0; y--) {
{ if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared) {
if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared) if (this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.LAVA.getInternalId()) {
{
if (this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.LAVA.getInternalId())
{
undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y)); undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y));
this.setBlockIdAt(this.getTargetBlock().getZ() + y, this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId()); this.setBlockIdAt(this.getTargetBlock().getZ() + y, this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId());
} }
if (this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.LAVA.getInternalId()) if (this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.LAVA.getInternalId()) {
{
undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y)); undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y));
this.setBlockIdAt(this.getTargetBlock().getZ() - y, this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId()); this.setBlockIdAt(this.getTargetBlock().getZ() - y, this.getTargetBlock().getX() + x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId());
} }
if (this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.LAVA.getInternalId()) if (this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y) == BlockTypes.LAVA.getInternalId()) {
{
undo.put(this.clampY(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y)); undo.put(this.clampY(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() + y));
this.setBlockIdAt(this.getTargetBlock().getZ() + y, this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId()); this.setBlockIdAt(this.getTargetBlock().getZ() + y, this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId());
} }
if (this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.LAVA.getInternalId()) if (this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y) == BlockTypes.LAVA.getInternalId()) {
{
undo.put(this.clampY(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y)); undo.put(this.clampY(this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), this.getTargetBlock().getZ() - y));
this.setBlockIdAt(this.getTargetBlock().getZ() - y, this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId()); this.setBlockIdAt(this.getTargetBlock().getZ() - y, this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId());
} }
} }
} }
} }
} } else {
else for (int y = (brushSize + 1) * 2; y >= 0; y--) {
{
for (int y = (brushSize + 1) * 2; y >= 0; y--)
{
final double ySquared = Math.pow(y - brushSize, 2); final double ySquared = Math.pow(y - brushSize, 2);
for (int x = (brushSize + 1) * 2; x >= 0; x--) for (int x = (brushSize + 1) * 2; x >= 0; x--) {
{
final double xSquared = Math.pow(x - brushSize, 2); final double xSquared = Math.pow(x - brushSize, 2);
for (int z = (brushSize + 1) * 2; z >= 0; z--) for (int z = (brushSize + 1) * 2; z >= 0; z--) {
{ if ((xSquared + Math.pow(z - brushSize, 2) + ySquared) <= brushSizeSquared) {
if ((xSquared + Math.pow(z - brushSize, 2) + ySquared) <= brushSizeSquared) if (this.getBlockIdAt(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, this.getTargetBlock().getZ() + y - brushSize) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, this.getTargetBlock().getZ() + y - brushSize) == BlockTypes.LAVA.getInternalId()) {
{
if (this.getBlockIdAt(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, this.getTargetBlock().getZ() + y - brushSize) == BlockTypes.WATER.getInternalId() || this.getBlockIdAt(this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, this.getTargetBlock().getZ() + y - brushSize) == BlockTypes.LAVA.getInternalId())
{
undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + z, this.getTargetBlock().getZ() + y)); undo.put(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + z, this.getTargetBlock().getZ() + y));
this.setBlockIdAt(this.getTargetBlock().getZ() + y - brushSize, this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, BlockTypes.AIR.getInternalId()); this.setBlockIdAt(this.getTargetBlock().getZ() + y - brushSize, this.getTargetBlock().getX() + x - brushSize, this.getTargetBlock().getY() + z - brushSize, BlockTypes.AIR.getInternalId());
} }
@ -100,20 +80,17 @@ public class DrainBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.drain(v); this.drain(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.drain(v); this.drain(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
@ -122,52 +99,37 @@ public class DrainBrush extends Brush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Drain Brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Drain Brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b drain true -- will use a true sphere algorithm instead of the skinnier version with classic sniper nubs. /b drain false will switch back. (false is default)"); v.sendMessage(ChatColor.AQUA + "/b drain true -- will use a true sphere algorithm instead of the skinnier version with classic sniper nubs. /b drain false will switch back. (false is default)");
v.sendMessage(ChatColor.AQUA + "/b drain d -- toggles disc drain mode, as opposed to a ball drain mode"); v.sendMessage(ChatColor.AQUA + "/b drain d -- toggles disc drain mode, as opposed to a ball drain mode");
return; return;
} } else if (parameter.startsWith("true")) {
else if (parameter.startsWith("true"))
{
this.trueCircle = 0.5; this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON."); v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
} } else if (parameter.startsWith("false")) {
else if (parameter.startsWith("false"))
{
this.trueCircle = 0; this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} } else if (parameter.equalsIgnoreCase("d")) {
else if (parameter.equalsIgnoreCase("d")) if (this.disc) {
{
if (this.disc)
{
this.disc = false; this.disc = false;
v.sendMessage(ChatColor.AQUA + "Disc drain mode OFF"); v.sendMessage(ChatColor.AQUA + "Disc drain mode OFF");
} } else {
else
{
this.disc = true; this.disc = true;
v.sendMessage(ChatColor.AQUA + "Disc drain mode ON"); v.sendMessage(ChatColor.AQUA + "Disc drain mode ON");
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.drain"; return "voxelsniper.brush.drain";
} }
} }

Datei anzeigen

@ -5,15 +5,13 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Ellipse_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#Ellipse_Brush
* *
* @author psanker * @author psanker
*/ */
public class EllipseBrush extends PerformBrush public class EllipseBrush extends PerformBrush {
{
private static final double TWO_PI = (2 * Math.PI); private static final double TWO_PI = (2 * Math.PI);
private static final int SCL_MIN = 1; private static final int SCL_MIN = 1;
private static final int SCL_MAX = 9999; private static final int SCL_MAX = 9999;
@ -30,22 +28,17 @@ public class EllipseBrush extends PerformBrush
/** /**
* *
*/ */
public EllipseBrush() public EllipseBrush() {
{
this.setName("Ellipse"); this.setName("Ellipse");
} }
private void ellipse(final SnipeData v, AsyncBlock targetBlock) private void ellipse(final SnipeData v, AsyncBlock targetBlock) {
{ try {
try for (double steps = 0; (steps <= TWO_PI); steps += stepSize) {
{
for (double steps = 0; (steps <= TWO_PI); steps += stepSize)
{
final int x = (int) Math.round(this.xscl * Math.cos(steps)); final int x = (int) Math.round(this.xscl * Math.cos(steps));
final int y = (int) Math.round(this.yscl * Math.sin(steps)); final int y = (int) Math.round(this.yscl * Math.sin(steps));
switch (getTargetBlock().getFace(this.getLastBlock())) switch (getTargetBlock().getFace(this.getLastBlock())) {
{
case NORTH: case NORTH:
case SOUTH: case SOUTH:
current.perform(targetBlock.getRelative(0, x, y)); current.perform(targetBlock.getRelative(0, x, y));
@ -61,40 +54,31 @@ public class EllipseBrush extends PerformBrush
break; break;
} }
if (steps >= TWO_PI) if (steps >= TWO_PI) {
{
break; break;
} }
} }
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "Invalid target."); v.sendMessage(ChatColor.RED + "Invalid target.");
} }
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void ellipsefill(final SnipeData v, AsyncBlock targetBlock) private void ellipsefill(final SnipeData v, AsyncBlock targetBlock) {
{
int ix = this.xscl; int ix = this.xscl;
int iy = this.yscl; int iy = this.yscl;
current.perform(targetBlock); current.perform(targetBlock);
try try {
{ if (ix >= iy) { // Need this unless you want weird holes
if (ix >= iy) for (iy = this.yscl; iy > 0; iy--) {
{ // Need this unless you want weird holes for (double steps = 0; (steps <= TWO_PI); steps += stepSize) {
for (iy = this.yscl; iy > 0; iy--)
{
for (double steps = 0; (steps <= TWO_PI); steps += stepSize)
{
final int x = (int) Math.round(ix * Math.cos(steps)); final int x = (int) Math.round(ix * Math.cos(steps));
final int y = (int) Math.round(iy * Math.sin(steps)); final int y = (int) Math.round(iy * Math.sin(steps));
switch (getTargetBlock().getFace(this.getLastBlock())) switch (getTargetBlock().getFace(this.getLastBlock())) {
{
case NORTH: case NORTH:
case SOUTH: case SOUTH:
current.perform(targetBlock.getRelative(0, x, y)); current.perform(targetBlock.getRelative(0, x, y));
@ -110,25 +94,19 @@ public class EllipseBrush extends PerformBrush
break; break;
} }
if (steps >= TWO_PI) if (steps >= TWO_PI) {
{
break; break;
} }
} }
ix--; ix--;
} }
} } else {
else for (ix = this.xscl; ix > 0; ix--) {
{ for (double steps = 0; (steps <= TWO_PI); steps += stepSize) {
for (ix = this.xscl; ix > 0; ix--)
{
for (double steps = 0; (steps <= TWO_PI); steps += stepSize)
{
final int x = (int) Math.round(ix * Math.cos(steps)); final int x = (int) Math.round(ix * Math.cos(steps));
final int y = (int) Math.round(iy * Math.sin(steps)); final int y = (int) Math.round(iy * Math.sin(steps));
switch (getTargetBlock().getFace(this.getLastBlock())) switch (getTargetBlock().getFace(this.getLastBlock())) {
{
case NORTH: case NORTH:
case SOUTH: case SOUTH:
current.perform(targetBlock.getRelative(0, x, y)); current.perform(targetBlock.getRelative(0, x, y));
@ -144,64 +122,51 @@ public class EllipseBrush extends PerformBrush
break; break;
} }
if (steps >= TWO_PI) if (steps >= TWO_PI) {
{
break; break;
} }
} }
iy--; iy--;
} }
} }
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "Invalid target."); v.sendMessage(ChatColor.RED + "Invalid target.");
} }
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void execute(final SnipeData v, AsyncBlock targetBlock) private void execute(final SnipeData v, AsyncBlock targetBlock) {
{
this.stepSize = (TWO_PI / this.steps); this.stepSize = (TWO_PI / this.steps);
if (this.fill) if (this.fill) {
{
this.ellipsefill(v, targetBlock); this.ellipsefill(v, targetBlock);
} } else {
else
{
this.ellipse(v, targetBlock); this.ellipse(v, targetBlock);
} }
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.execute(v, this.getTargetBlock()); this.execute(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.execute(v, this.getLastBlock()); this.execute(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{ if (this.xscl < SCL_MIN || this.xscl > SCL_MAX) {
if (this.xscl < SCL_MIN || this.xscl > SCL_MAX)
{
this.xscl = SCL_DEFAULT; this.xscl = SCL_DEFAULT;
} }
if (this.yscl < SCL_MIN || this.yscl > SCL_MAX) if (this.yscl < SCL_MIN || this.yscl > SCL_MAX) {
{
this.yscl = SCL_DEFAULT; this.yscl = SCL_DEFAULT;
} }
if (this.steps < STEPS_MIN || this.steps > STEPS_MAX) if (this.steps < STEPS_MIN || this.steps > STEPS_MAX) {
{
this.steps = STEPS_DEFAULT; this.steps = STEPS_DEFAULT;
} }
@ -209,96 +174,70 @@ public class EllipseBrush extends PerformBrush
vm.custom(ChatColor.AQUA + "X-size set to: " + ChatColor.DARK_AQUA + this.xscl); vm.custom(ChatColor.AQUA + "X-size set to: " + ChatColor.DARK_AQUA + this.xscl);
vm.custom(ChatColor.AQUA + "Y-size set to: " + ChatColor.DARK_AQUA + this.yscl); vm.custom(ChatColor.AQUA + "Y-size set to: " + ChatColor.DARK_AQUA + this.yscl);
vm.custom(ChatColor.AQUA + "Render step number set to: " + ChatColor.DARK_AQUA + this.steps); vm.custom(ChatColor.AQUA + "Render step number set to: " + ChatColor.DARK_AQUA + this.steps);
if (this.fill) if (this.fill) {
{
vm.custom(ChatColor.AQUA + "Fill mode is enabled"); vm.custom(ChatColor.AQUA + "Fill mode is enabled");
} } else {
else
{
vm.custom(ChatColor.AQUA + "Fill mode is disabled"); vm.custom(ChatColor.AQUA + "Fill mode is disabled");
} }
} }
@Override @Override
public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
try try {
{ if (parameter.equalsIgnoreCase("info")) {
if (parameter.equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Ellipse brush parameters"); v.sendMessage(ChatColor.GOLD + "Ellipse brush parameters");
v.sendMessage(ChatColor.AQUA + "x[n]: Set X size modifier to n"); v.sendMessage(ChatColor.AQUA + "x[n]: Set X size modifier to n");
v.sendMessage(ChatColor.AQUA + "y[n]: Set Y size modifier to n"); v.sendMessage(ChatColor.AQUA + "y[n]: Set Y size modifier to n");
v.sendMessage(ChatColor.AQUA + "t[n]: Set the amount of time steps"); v.sendMessage(ChatColor.AQUA + "t[n]: Set the amount of time steps");
v.sendMessage(ChatColor.AQUA + "fill: Toggles fill mode"); v.sendMessage(ChatColor.AQUA + "fill: Toggles fill mode");
return; return;
} } else if (parameter.startsWith("x")) {
else if (parameter.startsWith("x"))
{
int tempXScale = Integer.parseInt(par[i].replace("x", "")); int tempXScale = Integer.parseInt(par[i].replace("x", ""));
if (tempXScale < SCL_MIN || tempXScale > SCL_MAX) if (tempXScale < SCL_MIN || tempXScale > SCL_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Invalid X scale (" + SCL_MIN + "-" + SCL_MAX + ")"); v.sendMessage(ChatColor.AQUA + "Invalid X scale (" + SCL_MIN + "-" + SCL_MAX + ")");
continue; continue;
} }
this.xscl = tempXScale; this.xscl = tempXScale;
v.sendMessage(ChatColor.AQUA + "X-scale modifier set to: " + this.xscl); v.sendMessage(ChatColor.AQUA + "X-scale modifier set to: " + this.xscl);
} } else if (parameter.startsWith("y")) {
else if (parameter.startsWith("y"))
{
int tempYScale = Integer.parseInt(par[i].replace("y", "")); int tempYScale = Integer.parseInt(par[i].replace("y", ""));
if (tempYScale < SCL_MIN || tempYScale > SCL_MAX) if (tempYScale < SCL_MIN || tempYScale > SCL_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Invalid Y scale (" + SCL_MIN + "-" + SCL_MAX + ")"); v.sendMessage(ChatColor.AQUA + "Invalid Y scale (" + SCL_MIN + "-" + SCL_MAX + ")");
continue; continue;
} }
this.yscl = tempYScale; this.yscl = tempYScale;
v.sendMessage(ChatColor.AQUA + "Y-scale modifier set to: " + this.yscl); v.sendMessage(ChatColor.AQUA + "Y-scale modifier set to: " + this.yscl);
} } else if (parameter.startsWith("t")) {
else if (parameter.startsWith("t"))
{
int tempSteps = Integer.parseInt(par[i].replace("t", "")); int tempSteps = Integer.parseInt(par[i].replace("t", ""));
if (tempSteps < STEPS_MIN || tempSteps > STEPS_MAX) if (tempSteps < STEPS_MIN || tempSteps > STEPS_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Invalid step number (" + STEPS_MIN + "-" + STEPS_MAX + ")"); v.sendMessage(ChatColor.AQUA + "Invalid step number (" + STEPS_MIN + "-" + STEPS_MAX + ")");
continue; continue;
} }
this.steps = tempSteps; this.steps = tempSteps;
v.sendMessage(ChatColor.AQUA + "Render step number set to: " + this.steps); v.sendMessage(ChatColor.AQUA + "Render step number set to: " + this.steps);
} } else if (parameter.equalsIgnoreCase("fill")) {
else if (parameter.equalsIgnoreCase("fill")) if (this.fill) {
{
if (this.fill)
{
this.fill = false; this.fill = false;
v.sendMessage(ChatColor.AQUA + "Fill mode is disabled"); v.sendMessage(ChatColor.AQUA + "Fill mode is disabled");
} } else {
else
{
this.fill = true; this.fill = true;
v.sendMessage(ChatColor.AQUA + "Fill mode is enabled"); v.sendMessage(ChatColor.AQUA + "Fill mode is enabled");
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the \"info\" parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the \"info\" parameter to display parameter info.");
} }
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "Incorrect parameter \"" + parameter + "\"; use the \"info\" parameter."); v.sendMessage(ChatColor.RED + "Incorrect parameter \"" + parameter + "\"; use the \"info\" parameter.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.ellipse"; return "voxelsniper.brush.ellipse";
} }
} }

Datei anzeigen

@ -5,14 +5,11 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Ellipsoid_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#Ellipsoid_Brush
*
*/ */
public class EllipsoidBrush extends PerformBrush public class EllipsoidBrush extends PerformBrush {
{
private double xRad; private double xRad;
private double yRad; private double yRad;
private double zRad; private double zRad;
@ -21,36 +18,30 @@ public class EllipsoidBrush extends PerformBrush
/** /**
* *
*/ */
public EllipsoidBrush() public EllipsoidBrush() {
{
this.setName("Ellipsoid"); this.setName("Ellipsoid");
} }
private void execute(final SnipeData v, AsyncBlock targetBlock) private void execute(final SnipeData v, AsyncBlock targetBlock) {
{
this.current.perform(targetBlock); this.current.perform(targetBlock);
double istrueoffset = istrue ? 0.5 : 0; double istrueoffset = istrue ? 0.5 : 0;
int blockPositionX = targetBlock.getX(); int blockPositionX = targetBlock.getX();
int blockPositionY = targetBlock.getY(); int blockPositionY = targetBlock.getY();
int blockPositionZ = targetBlock.getZ(); int blockPositionZ = targetBlock.getZ();
for (double x = 0; x <= xRad; x++) for (double x = 0; x <= xRad; x++) {
{
final double xSquared = (x / (xRad + istrueoffset)) * (x / (xRad + istrueoffset)); final double xSquared = (x / (xRad + istrueoffset)) * (x / (xRad + istrueoffset));
for (double z = 0; z <= zRad; z++) for (double z = 0; z <= zRad; z++) {
{
final double zSquared = (z / (zRad + istrueoffset)) * (z / (zRad + istrueoffset)); final double zSquared = (z / (zRad + istrueoffset)) * (z / (zRad + istrueoffset));
for (double y = 0; y <= yRad; y++) for (double y = 0; y <= yRad; y++) {
{
final double ySquared = (y / (yRad + istrueoffset)) * (y / (yRad + istrueoffset)); final double ySquared = (y / (yRad + istrueoffset)) * (y / (yRad + istrueoffset));
if (xSquared + ySquared + zSquared <= 1) if (xSquared + ySquared + zSquared <= 1) {
{
this.current.perform(this.clampY((int) (blockPositionX + x), (int) (blockPositionY + y), (int) (blockPositionZ + z))); this.current.perform(this.clampY((int) (blockPositionX + x), (int) (blockPositionY + y), (int) (blockPositionZ + z)));
this.current.perform(this.clampY((int) (blockPositionX + x), (int) (blockPositionY + y), (int) (blockPositionZ - z))); this.current.perform(this.clampY((int) (blockPositionX + x), (int) (blockPositionY + y), (int) (blockPositionZ - z)));
this.current.perform(this.clampY((int) (blockPositionX + x), (int) (blockPositionY - y), (int) (blockPositionZ + z))); this.current.perform(this.clampY((int) (blockPositionX + x), (int) (blockPositionY - y), (int) (blockPositionZ + z)));
@ -69,20 +60,17 @@ public class EllipsoidBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.execute(v, this.getTargetBlock()); this.execute(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.execute(v, this.getLastBlock()); this.execute(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.AQUA + "X-size set to: " + ChatColor.DARK_AQUA + this.xRad); vm.custom(ChatColor.AQUA + "X-size set to: " + ChatColor.DARK_AQUA + this.xRad);
vm.custom(ChatColor.AQUA + "Y-size set to: " + ChatColor.DARK_AQUA + this.yRad); vm.custom(ChatColor.AQUA + "Y-size set to: " + ChatColor.DARK_AQUA + this.yRad);
@ -90,58 +78,41 @@ public class EllipsoidBrush extends PerformBrush
} }
@Override @Override
public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) {
{
this.istrue = false; this.istrue = false;
for (int i = 1; i < par.length; i++) for (int i = 1; i < par.length; i++) {
{
final String parameter = par[i]; final String parameter = par[i];
try try {
{ if (parameter.equalsIgnoreCase("info")) {
if (parameter.equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Ellipse brush parameters"); v.sendMessage(ChatColor.GOLD + "Ellipse brush parameters");
v.sendMessage(ChatColor.AQUA + "x[n]: Set X radius to n"); v.sendMessage(ChatColor.AQUA + "x[n]: Set X radius to n");
v.sendMessage(ChatColor.AQUA + "y[n]: Set Y radius to n"); v.sendMessage(ChatColor.AQUA + "y[n]: Set Y radius to n");
v.sendMessage(ChatColor.AQUA + "z[n]: Set Z radius to n"); v.sendMessage(ChatColor.AQUA + "z[n]: Set Z radius to n");
return; return;
} } else if (parameter.startsWith("x")) {
else if (parameter.startsWith("x"))
{
this.xRad = Integer.parseInt(par[i].replace("x", "")); this.xRad = Integer.parseInt(par[i].replace("x", ""));
v.sendMessage(ChatColor.AQUA + "X radius set to: " + this.xRad); v.sendMessage(ChatColor.AQUA + "X radius set to: " + this.xRad);
} } else if (parameter.startsWith("y")) {
else if (parameter.startsWith("y"))
{
this.yRad = Integer.parseInt(par[i].replace("y", "")); this.yRad = Integer.parseInt(par[i].replace("y", ""));
v.sendMessage(ChatColor.AQUA + "Y radius set to: " + this.yRad); v.sendMessage(ChatColor.AQUA + "Y radius set to: " + this.yRad);
} } else if (parameter.startsWith("z")) {
else if (parameter.startsWith("z"))
{
this.zRad = Integer.parseInt(par[i].replace("z", "")); this.zRad = Integer.parseInt(par[i].replace("z", ""));
v.sendMessage(ChatColor.AQUA + "Z radius set to: " + this.zRad); v.sendMessage(ChatColor.AQUA + "Z radius set to: " + this.zRad);
} } else if (parameter.equalsIgnoreCase("true")) {
else if (parameter.equalsIgnoreCase("true"))
{
this.istrue = true; this.istrue = true;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the \"info\" parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the \"info\" parameter to display parameter info.");
} }
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "Incorrect parameter \"" + parameter + "\"; use the \"info\" parameter."); v.sendMessage(ChatColor.RED + "Incorrect parameter \"" + parameter + "\"; use the \"info\" parameter.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.ellipsoid"; return "voxelsniper.brush.ellipsoid";
} }
} }

Datei anzeigen

@ -2,7 +2,6 @@ package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -11,88 +10,69 @@ import org.bukkit.entity.EntityType;
* *
* @author Piotr * @author Piotr
*/ */
public class EntityBrush extends Brush public class EntityBrush extends Brush {
{
private EntityType entityType = EntityType.ZOMBIE; private EntityType entityType = EntityType.ZOMBIE;
/** /**
* *
*/ */
public EntityBrush() public EntityBrush() {
{
this.setName("Entity"); this.setName("Entity");
} }
private void spawn(final SnipeData v) private void spawn(final SnipeData v) {
{ for (int x = 0; x < v.getBrushSize(); x++) {
for (int x = 0; x < v.getBrushSize(); x++) try {
{
try
{
this.getWorld().spawn(this.getLastBlock().getLocation(), this.entityType.getEntityClass()); this.getWorld().spawn(this.getLastBlock().getLocation(), this.entityType.getEntityClass());
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception)
{
v.sendMessage(ChatColor.RED + "Cannot spawn entity!"); v.sendMessage(ChatColor.RED + "Cannot spawn entity!");
} }
} }
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.spawn(v); this.spawn(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.spawn(v); this.spawn(v);
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushMessage(ChatColor.LIGHT_PURPLE + "Entity brush" + " (" + this.entityType.getName() + ")"); vm.brushMessage(ChatColor.LIGHT_PURPLE + "Entity brush" + " (" + this.entityType.getName() + ")");
vm.size(); vm.size();
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
String names = ""; String names = "";
v.sendMessage(ChatColor.BLUE + "The available entity types are as follows:"); v.sendMessage(ChatColor.BLUE + "The available entity types are as follows:");
for (final EntityType currentEntity : EntityType.values()) for (final EntityType currentEntity : EntityType.values()) {
{
names += ChatColor.AQUA + " | " + ChatColor.DARK_GREEN + currentEntity.getName(); names += ChatColor.AQUA + " | " + ChatColor.DARK_GREEN + currentEntity.getName();
} }
names += ChatColor.AQUA + " |"; names += ChatColor.AQUA + " |";
v.sendMessage(names); v.sendMessage(names);
} } else {
else
{
final EntityType currentEntity = EntityType.fromName(par[1]); final EntityType currentEntity = EntityType.fromName(par[1]);
if (currentEntity != null) if (currentEntity != null) {
{
this.entityType = currentEntity; this.entityType = currentEntity;
v.sendMessage(ChatColor.GREEN + "Entity type set to " + this.entityType.getName()); v.sendMessage(ChatColor.GREEN + "Entity type set to " + this.entityType.getName());
} } else {
else
{
v.sendMessage(ChatColor.RED + "This is not a valid entity!"); v.sendMessage(ChatColor.RED + "This is not a valid entity!");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.entity"; return "voxelsniper.brush.entity";
} }
} }

Datei anzeigen

@ -14,15 +14,13 @@ import java.util.regex.PatternSyntaxException;
/** /**
* *
*/ */
public class EntityRemovalBrush extends Brush public class EntityRemovalBrush extends Brush {
{
private final List<String> exemptions = new ArrayList<>(3); private final List<String> exemptions = new ArrayList<>(3);
/** /**
* *
*/ */
public EntityRemovalBrush() public EntityRemovalBrush() {
{
this.setName("Entity Removal"); this.setName("Entity Removal");
exemptions.add("org.bukkit.entity.Player"); exemptions.add("org.bukkit.entity.Player");
@ -30,30 +28,24 @@ public class EntityRemovalBrush extends Brush
exemptions.add("org.bukkit.entity.NPC"); exemptions.add("org.bukkit.entity.NPC");
} }
private void radialRemoval(SnipeData v) private void radialRemoval(SnipeData v) {
{
final Chunk targetChunk = getTargetBlock().getChunk(); final Chunk targetChunk = getTargetBlock().getChunk();
int entityCount = 0; int entityCount = 0;
int chunkCount = 0; int chunkCount = 0;
try try {
{
entityCount += removeEntities(targetChunk); entityCount += removeEntities(targetChunk);
int radius = Math.round(v.getBrushSize() / 16); int radius = Math.round(v.getBrushSize() / 16);
for (int x = targetChunk.getX() - radius; x <= targetChunk.getX() + radius; x++) for (int x = targetChunk.getX() - radius; x <= targetChunk.getX() + radius; x++) {
{ for (int z = targetChunk.getZ() - radius; z <= targetChunk.getZ() + radius; z++) {
for (int z = targetChunk.getZ() - radius; z <= targetChunk.getZ() + radius; z++)
{
entityCount += removeEntities(getWorld().getChunkAt(x, z)); entityCount += removeEntities(getWorld().getChunkAt(x, z));
chunkCount++; chunkCount++;
} }
} }
} } catch (final PatternSyntaxException pse) {
catch (final PatternSyntaxException pse)
{
pse.printStackTrace(); pse.printStackTrace();
v.sendMessage(ChatColor.RED + "Error in RegEx: " + ChatColor.LIGHT_PURPLE + pse.getPattern()); v.sendMessage(ChatColor.RED + "Error in RegEx: " + ChatColor.LIGHT_PURPLE + pse.getPattern());
v.sendMessage(ChatColor.RED + String.format("%s (Index: %d)", pse.getDescription(), pse.getIndex())); v.sendMessage(ChatColor.RED + String.format("%s (Index: %d)", pse.getDescription(), pse.getIndex()));
@ -61,14 +53,11 @@ public class EntityRemovalBrush extends Brush
v.sendMessage(ChatColor.GREEN + "Removed " + ChatColor.RED + entityCount + ChatColor.GREEN + " entities out of " + ChatColor.BLUE + chunkCount + ChatColor.GREEN + (chunkCount == 1 ? " chunk." : " chunks.")); v.sendMessage(ChatColor.GREEN + "Removed " + ChatColor.RED + entityCount + ChatColor.GREEN + " entities out of " + ChatColor.BLUE + chunkCount + ChatColor.GREEN + (chunkCount == 1 ? " chunk." : " chunks."));
} }
private int removeEntities(Chunk chunk) throws PatternSyntaxException private int removeEntities(Chunk chunk) throws PatternSyntaxException {
{
int entityCount = 0; int entityCount = 0;
for (Entity entity : chunk.getEntities()) for (Entity entity : chunk.getEntities()) {
{ if (isClassInExemptionList(entity.getClass())) {
if (isClassInExemptionList(entity.getClass()))
{
continue; continue;
} }
@ -79,30 +68,24 @@ public class EntityRemovalBrush extends Brush
return entityCount; return entityCount;
} }
private boolean isClassInExemptionList(Class<? extends Entity> entityClass) throws PatternSyntaxException private boolean isClassInExemptionList(Class<? extends Entity> entityClass) throws PatternSyntaxException {
{
// Create a list of superclasses and interfaces implemented by the current entity type // Create a list of superclasses and interfaces implemented by the current entity type
final List<String> entityClassHierarchy = new ArrayList<>(); final List<String> entityClassHierarchy = new ArrayList<>();
Class<?> currentClass = entityClass; Class<?> currentClass = entityClass;
while (currentClass != null && !currentClass.equals(Object.class)) while (currentClass != null && !currentClass.equals(Object.class)) {
{
entityClassHierarchy.add(currentClass.getCanonicalName()); entityClassHierarchy.add(currentClass.getCanonicalName());
for (final Class<?> intrf : currentClass.getInterfaces()) for (final Class<?> intrf : currentClass.getInterfaces()) {
{
entityClassHierarchy.add(intrf.getCanonicalName()); entityClassHierarchy.add(intrf.getCanonicalName());
} }
currentClass = currentClass.getSuperclass(); currentClass = currentClass.getSuperclass();
} }
for (final String exemptionPattern : exemptions) for (final String exemptionPattern : exemptions) {
{ for (final String typeName : entityClassHierarchy) {
for (final String typeName : entityClassHierarchy) if (typeName.matches(exemptionPattern)) {
{
if (typeName.matches(exemptionPattern))
{
return true; return true;
} }
@ -113,28 +96,23 @@ public class EntityRemovalBrush extends Brush
} }
@Override @Override
protected void arrow(SnipeData v) protected void arrow(SnipeData v) {
{
this.radialRemoval(v); this.radialRemoval(v);
} }
@Override @Override
protected void powder(SnipeData v) protected void powder(SnipeData v) {
{
this.radialRemoval(v); this.radialRemoval(v);
} }
@Override @Override
public void info(Message vm) public void info(Message vm) {
{
vm.brushName(getName()); vm.brushName(getName());
final StringBuilder exemptionsList = new StringBuilder(ChatColor.GREEN + "Exemptions: " + ChatColor.LIGHT_PURPLE); final StringBuilder exemptionsList = new StringBuilder(ChatColor.GREEN + "Exemptions: " + ChatColor.LIGHT_PURPLE);
for (Iterator it = exemptions.iterator(); it.hasNext(); ) for (Iterator it = exemptions.iterator(); it.hasNext(); ) {
{
exemptionsList.append(it.next()); exemptionsList.append(it.next());
if (it.hasNext()) if (it.hasNext()) {
{
exemptionsList.append(", "); exemptionsList.append(", ");
} }
} }
@ -144,12 +122,9 @@ public class EntityRemovalBrush extends Brush
} }
@Override @Override
public void parameters(final String[] par, final SnipeData v) public void parameters(final String[] par, final SnipeData v) {
{ for (final String currentParam : par) {
for (final String currentParam : par) if (currentParam.startsWith("+") || currentParam.startsWith("-")) {
{
if (currentParam.startsWith("+") || currentParam.startsWith("-"))
{
final boolean isAddOperation = currentParam.startsWith("+"); final boolean isAddOperation = currentParam.startsWith("+");
// +#/-# will suppress auto-prefixing // +#/-# will suppress auto-prefixing
@ -157,22 +132,17 @@ public class EntityRemovalBrush extends Brush
currentParam.substring(2) : currentParam.substring(2) :
(currentParam.contains(".") ? currentParam.substring(1) : ".*." + currentParam.substring(1)); (currentParam.contains(".") ? currentParam.substring(1) : ".*." + currentParam.substring(1));
if (isAddOperation) if (isAddOperation) {
{
exemptions.add(exemptionPattern); exemptions.add(exemptionPattern);
v.sendMessage(String.format("Added %s to entity exemptions list.", exemptionPattern)); v.sendMessage(String.format("Added %s to entity exemptions list.", exemptionPattern));
} } else {
else
{
exemptions.remove(exemptionPattern); exemptions.remove(exemptionPattern);
v.sendMessage(String.format("Removed %s from entity exemptions list.", exemptionPattern)); v.sendMessage(String.format("Removed %s from entity exemptions list.", exemptionPattern));
} }
} }
if (currentParam.equalsIgnoreCase("list-exemptions") || currentParam.equalsIgnoreCase("lex")) if (currentParam.equalsIgnoreCase("list-exemptions") || currentParam.equalsIgnoreCase("lex")) {
{ for (final String exemption : exemptions) {
for (final String exemption : exemptions)
{
v.sendMessage(ChatColor.LIGHT_PURPLE + exemption); v.sendMessage(ChatColor.LIGHT_PURPLE + exemption);
} }
} }
@ -180,8 +150,7 @@ public class EntityRemovalBrush extends Brush
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.entityremoval"; return "voxelsniper.brush.entityremoval";
} }
} }

Datei anzeigen

@ -3,20 +3,19 @@ package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import java.util.EnumSet;
import java.util.Set;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import java.util.EnumSet;
import java.util.Set;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Eraser_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#Eraser_Brush
* *
* @author Voxel * @author Voxel
*/ */
public class EraserBrush extends Brush public class EraserBrush extends Brush {
{
private static final Set<Material> EXCLUSIVE_MATERIALS = EnumSet.of( private static final Set<Material> EXCLUSIVE_MATERIALS = EnumSet.of(
Material.AIR, Material.STONE, Material.GRASS, Material.DIRT, Material.SAND, Material.GRAVEL, Material.SANDSTONE); Material.AIR, Material.STONE, Material.GRASS, Material.DIRT, Material.SAND, Material.GRAVEL, Material.SANDSTONE);
@ -26,31 +25,25 @@ public class EraserBrush extends Brush
/** /**
* *
*/ */
public EraserBrush() public EraserBrush() {
{
this.setName("Eraser"); this.setName("Eraser");
} }
private void doErase(final SnipeData v, final boolean keepWater) private void doErase(final SnipeData v, final boolean keepWater) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final int brushSizeDoubled = 2 * brushSize; final int brushSizeDoubled = 2 * brushSize;
World world = this.getTargetBlock().getWorld(); World world = this.getTargetBlock().getWorld();
final Undo undo = new Undo(); final Undo undo = new Undo();
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{
int currentX = this.getTargetBlock().getX() - brushSize + x; int currentX = this.getTargetBlock().getX() - brushSize + x;
for (int y = 0; y <= brushSizeDoubled; y++) for (int y = 0; y <= brushSizeDoubled; y++) {
{
int currentY = this.getTargetBlock().getY() - brushSize + y; int currentY = this.getTargetBlock().getY() - brushSize + y;
for (int z = brushSizeDoubled; z >= 0; z--) for (int z = brushSizeDoubled; z >= 0; z--) {
{
int currentZ = this.getTargetBlock().getZ() - brushSize + z; int currentZ = this.getTargetBlock().getZ() - brushSize + z;
Block currentBlock = world.getBlockAt(currentX, currentY, currentZ); Block currentBlock = world.getBlockAt(currentX, currentY, currentZ);
if (EXCLUSIVE_MATERIALS.contains(currentBlock.getType()) if (EXCLUSIVE_MATERIALS.contains(currentBlock.getType())
|| (keepWater && EXCLUSIVE_LIQUIDS.contains(currentBlock.getType()))) || (keepWater && EXCLUSIVE_LIQUIDS.contains(currentBlock.getType()))) {
{
continue; continue;
} }
undo.put(currentBlock); undo.put(currentBlock);
@ -62,27 +55,23 @@ public class EraserBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.doErase(v, false); this.doErase(v, false);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.doErase(v, true); this.doErase(v, true);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.eraser"; return "voxelsniper.brush.eraser";
} }
} }

Datei anzeigen

@ -20,11 +20,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.ChatPaginator; import org.bukkit.util.ChatPaginator;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.Arrays; import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* http://www.voxelwiki.com/minecraft/VoxelSniper#The_Erosion_Brush * http://www.voxelwiki.com/minecraft/VoxelSniper#The_Erosion_Brush
@ -32,8 +28,7 @@ import java.util.Map;
* @author Piotr * @author Piotr
* @author MikeMatrix * @author MikeMatrix
*/ */
public class ErodeBrush extends Brush public class ErodeBrush extends Brush {
{
private static final Vector[] FACES_TO_CHECK = {new Vector(0, 0, 1), new Vector(0, 0, -1), new Vector(0, 1, 0), new Vector(0, -1, 0), new Vector(1, 0, 0), new Vector(-1, 0, 0)}; private static final Vector[] FACES_TO_CHECK = {new Vector(0, 0, 1), new Vector(0, 0, -1), new Vector(0, 1, 0), new Vector(0, -1, 0), new Vector(1, 0, 0), new Vector(-1, 0, 0)};
private final HelpJSAP parser = new HelpJSAP("/b e", "Brush for eroding landscape.", ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH); private final HelpJSAP parser = new HelpJSAP("/b e", "Brush for eroding landscape.", ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH);
private ErosionPreset currentPreset = new ErosionPreset(0, 1, 0, 1); private ErosionPreset currentPreset = new ErosionPreset(0, 1, 0, 1);
@ -41,20 +36,16 @@ public class ErodeBrush extends Brush
/** /**
* *
*/ */
public ErodeBrush() public ErodeBrush() {
{
this.setName("Erode"); this.setName("Erode");
try try {
{
this.parser.registerParameter(new UnflaggedOption("preset", EnumeratedStringParser.getParser(Preset.getValuesString(";"), false), null, false, false, "Preset options: " + Preset.getValuesString(", "))); this.parser.registerParameter(new UnflaggedOption("preset", EnumeratedStringParser.getParser(Preset.getValuesString(";"), false), null, false, false, "Preset options: " + Preset.getValuesString(", ")));
this.parser.registerParameter(new FlaggedOption("fill", NullableIntegerStringParser.getParser(), null, false, 'f', "fill", "Surrounding blocks required to fill the block.")); this.parser.registerParameter(new FlaggedOption("fill", NullableIntegerStringParser.getParser(), null, false, 'f', "fill", "Surrounding blocks required to fill the block."));
this.parser.registerParameter(new FlaggedOption("erode", NullableIntegerStringParser.getParser(), null, false, 'e', "erode", "Surrounding air required to erode the block.")); this.parser.registerParameter(new FlaggedOption("erode", NullableIntegerStringParser.getParser(), null, false, 'e', "erode", "Surrounding air required to erode the block."));
this.parser.registerParameter(new FlaggedOption("fillrecursion", NullableIntegerStringParser.getParser(), null, false, 'F', "fillrecursion", "Repeated fill iterations.")); this.parser.registerParameter(new FlaggedOption("fillrecursion", NullableIntegerStringParser.getParser(), null, false, 'F', "fillrecursion", "Repeated fill iterations."));
this.parser.registerParameter(new FlaggedOption("eroderecursion", NullableIntegerStringParser.getParser(), null, false, 'E', "eroderecursion", "Repeated erode iterations.")); this.parser.registerParameter(new FlaggedOption("eroderecursion", NullableIntegerStringParser.getParser(), null, false, 'E', "eroderecursion", "Repeated erode iterations."));
} } catch (JSAPException ignored) {
catch (JSAPException ignored)
{
} }
} }
@ -64,13 +55,10 @@ public class ErodeBrush extends Brush
* @param helpJSAP * @param helpJSAP
* @return if a message was sent. * @return if a message was sent.
*/ */
public static boolean sendHelpOrErrorMessageToPlayer(final JSAPResult result, final Player player, final HelpJSAP helpJSAP) public static boolean sendHelpOrErrorMessageToPlayer(final JSAPResult result, final Player player, final HelpJSAP helpJSAP) {
{
final List<String> output = helpJSAP.writeHelpOrErrorMessageIfRequired(result); final List<String> output = helpJSAP.writeHelpOrErrorMessageIfRequired(result);
if (!output.isEmpty()) if (!output.isEmpty()) {
{ for (final String string : output) {
for (final String string : output)
{
player.sendMessage(string); player.sendMessage(string);
} }
return true; return true;
@ -79,32 +67,27 @@ public class ErodeBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.erosion(v, this.currentPreset); this.erosion(v, this.currentPreset);
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void erosion(final SnipeData v, final ErosionPreset erosionPreset) private void erosion(final SnipeData v, final ErosionPreset erosionPreset) {
{
final BlockChangeTracker blockChangeTracker = new BlockChangeTracker(this.getTargetBlock().getWorld()); final BlockChangeTracker blockChangeTracker = new BlockChangeTracker(this.getTargetBlock().getWorld());
final Vector targetBlockVector = this.getTargetBlock().getLocation().toVector(); final Vector targetBlockVector = this.getTargetBlock().getLocation().toVector();
for (int i = 0; i < erosionPreset.getErosionRecursion(); ++i) for (int i = 0; i < erosionPreset.getErosionRecursion(); ++i) {
{
erosionIteration(v, erosionPreset, blockChangeTracker, targetBlockVector); erosionIteration(v, erosionPreset, blockChangeTracker, targetBlockVector);
} }
for (int i = 0; i < erosionPreset.getFillRecursion(); ++i) for (int i = 0; i < erosionPreset.getFillRecursion(); ++i) {
{
fillIteration(v, erosionPreset, blockChangeTracker, targetBlockVector); fillIteration(v, erosionPreset, blockChangeTracker, targetBlockVector);
} }
final Undo undo = new Undo(); final Undo undo = new Undo();
for (final BlockWrapper blockWrapper : blockChangeTracker.getAll()) for (final BlockWrapper blockWrapper : blockChangeTracker.getAll()) {
{
undo.put(blockWrapper.getBlock()); undo.put(blockWrapper.getBlock());
blockWrapper.getBlock().setTypeIdAndPropertyId(BukkitAdapter.adapt(blockWrapper.getMaterial()).getInternalId(), blockWrapper.getPropertyId(), true); blockWrapper.getBlock().setTypeIdAndPropertyId(BukkitAdapter.adapt(blockWrapper.getMaterial()).getInternalId(), blockWrapper.getPropertyId(), true);
} }
@ -112,22 +95,16 @@ public class ErodeBrush extends Brush
v.owner().storeUndo(undo); v.owner().storeUndo(undo);
} }
private void fillIteration(final SnipeData v, final ErosionPreset erosionPreset, final BlockChangeTracker blockChangeTracker, final Vector targetBlockVector) private void fillIteration(final SnipeData v, final ErosionPreset erosionPreset, final BlockChangeTracker blockChangeTracker, final Vector targetBlockVector) {
{
final int currentIteration = blockChangeTracker.nextIteration(); final int currentIteration = blockChangeTracker.nextIteration();
for (int x = this.getTargetBlock().getX() - v.getBrushSize(); x <= this.getTargetBlock().getX() + v.getBrushSize(); ++x) for (int x = this.getTargetBlock().getX() - v.getBrushSize(); x <= this.getTargetBlock().getX() + v.getBrushSize(); ++x) {
{ for (int z = this.getTargetBlock().getZ() - v.getBrushSize(); z <= this.getTargetBlock().getZ() + v.getBrushSize(); ++z) {
for (int z = this.getTargetBlock().getZ() - v.getBrushSize(); z <= this.getTargetBlock().getZ() + v.getBrushSize(); ++z) for (int y = this.getTargetBlock().getY() - v.getBrushSize(); y <= this.getTargetBlock().getY() + v.getBrushSize(); ++y) {
{
for (int y = this.getTargetBlock().getY() - v.getBrushSize(); y <= this.getTargetBlock().getY() + v.getBrushSize(); ++y)
{
final Vector currentPosition = new Vector(x, y, z); final Vector currentPosition = new Vector(x, y, z);
if (currentPosition.isInSphere(targetBlockVector, v.getBrushSize())) if (currentPosition.isInSphere(targetBlockVector, v.getBrushSize())) {
{
final BlockWrapper currentBlock = blockChangeTracker.get(currentPosition, currentIteration); final BlockWrapper currentBlock = blockChangeTracker.get(currentPosition, currentIteration);
if (!(currentBlock.isEmpty() || currentBlock.isLiquid())) if (!(currentBlock.isEmpty() || currentBlock.isLiquid())) {
{
continue; continue;
} }
@ -135,41 +112,33 @@ public class ErodeBrush extends Brush
final Map<BlockWrapper, Integer> blockCount = new HashMap<>(); final Map<BlockWrapper, Integer> blockCount = new HashMap<>();
for (final Vector vector : ErodeBrush.FACES_TO_CHECK) for (final Vector vector : ErodeBrush.FACES_TO_CHECK) {
{
final Vector relativePosition = currentPosition.clone().add(vector); final Vector relativePosition = currentPosition.clone().add(vector);
final BlockWrapper relativeBlock = blockChangeTracker.get(relativePosition, currentIteration); final BlockWrapper relativeBlock = blockChangeTracker.get(relativePosition, currentIteration);
if (!(relativeBlock.isEmpty() || relativeBlock.isLiquid())) if (!(relativeBlock.isEmpty() || relativeBlock.isLiquid())) {
{
count++; count++;
final BlockWrapper typeBlock = new BlockWrapper(null, relativeBlock.getMaterial(), relativeBlock.getPropertyId()); final BlockWrapper typeBlock = new BlockWrapper(null, relativeBlock.getMaterial(), relativeBlock.getPropertyId());
if (blockCount.containsKey(typeBlock)) if (blockCount.containsKey(typeBlock)) {
{
blockCount.put(typeBlock, blockCount.get(typeBlock) + 1); blockCount.put(typeBlock, blockCount.get(typeBlock) + 1);
} } else {
else
{
blockCount.put(typeBlock, 1); blockCount.put(typeBlock, 1);
} }
} }
} }
BlockWrapper currentMaterial = new BlockWrapper(null, Material.AIR, 0); BlockWrapper currentMaterial = new BlockWrapper(null, Material.AIR, 0);
int amount = 0; int amount = 0;
for (final BlockWrapper wrapper : blockCount.keySet()) for (final BlockWrapper wrapper : blockCount.keySet()) {
{
final Integer currentCount = blockCount.get(wrapper); final Integer currentCount = blockCount.get(wrapper);
if (amount <= currentCount) if (amount <= currentCount) {
{
currentMaterial = wrapper; currentMaterial = wrapper;
amount = currentCount; amount = currentCount;
} }
} }
if (count >= erosionPreset.getFillFaces()) if (count >= erosionPreset.getFillFaces()) {
{
blockChangeTracker.put(currentPosition, new BlockWrapper(currentBlock.getBlock(), currentMaterial.getMaterial(), currentMaterial.getPropertyId()), currentIteration); blockChangeTracker.put(currentPosition, new BlockWrapper(currentBlock.getBlock(), currentMaterial.getMaterial(), currentMaterial.getPropertyId()), currentIteration);
} }
} }
@ -178,40 +147,31 @@ public class ErodeBrush extends Brush
} }
} }
private void erosionIteration(final SnipeData v, final ErosionPreset erosionPreset, final BlockChangeTracker blockChangeTracker, final Vector targetBlockVector) private void erosionIteration(final SnipeData v, final ErosionPreset erosionPreset, final BlockChangeTracker blockChangeTracker, final Vector targetBlockVector) {
{
final int currentIteration = blockChangeTracker.nextIteration(); final int currentIteration = blockChangeTracker.nextIteration();
for (int x = this.getTargetBlock().getX() - v.getBrushSize(); x <= this.getTargetBlock().getX() + v.getBrushSize(); ++x) for (int x = this.getTargetBlock().getX() - v.getBrushSize(); x <= this.getTargetBlock().getX() + v.getBrushSize(); ++x) {
{ for (int z = this.getTargetBlock().getZ() - v.getBrushSize(); z <= this.getTargetBlock().getZ() + v.getBrushSize(); ++z) {
for (int z = this.getTargetBlock().getZ() - v.getBrushSize(); z <= this.getTargetBlock().getZ() + v.getBrushSize(); ++z) for (int y = this.getTargetBlock().getY() - v.getBrushSize(); y <= this.getTargetBlock().getY() + v.getBrushSize(); ++y) {
{
for (int y = this.getTargetBlock().getY() - v.getBrushSize(); y <= this.getTargetBlock().getY() + v.getBrushSize(); ++y)
{
final Vector currentPosition = new Vector(x, y, z); final Vector currentPosition = new Vector(x, y, z);
if (currentPosition.isInSphere(targetBlockVector, v.getBrushSize())) if (currentPosition.isInSphere(targetBlockVector, v.getBrushSize())) {
{
final BlockWrapper currentBlock = blockChangeTracker.get(currentPosition, currentIteration); final BlockWrapper currentBlock = blockChangeTracker.get(currentPosition, currentIteration);
if (currentBlock.isEmpty() || currentBlock.isLiquid()) if (currentBlock.isEmpty() || currentBlock.isLiquid()) {
{
continue; continue;
} }
int count = 0; int count = 0;
for (final Vector vector : ErodeBrush.FACES_TO_CHECK) for (final Vector vector : ErodeBrush.FACES_TO_CHECK) {
{
final Vector relativePosition = currentPosition.clone().add(vector); final Vector relativePosition = currentPosition.clone().add(vector);
final BlockWrapper relativeBlock = blockChangeTracker.get(relativePosition, currentIteration); final BlockWrapper relativeBlock = blockChangeTracker.get(relativePosition, currentIteration);
if (relativeBlock.isEmpty() || relativeBlock.isLiquid()) if (relativeBlock.isEmpty() || relativeBlock.isLiquid()) {
{
count++; count++;
} }
} }
if (count >= erosionPreset.getErosionFaces()) if (count >= erosionPreset.getErosionFaces()) {
{ blockChangeTracker.put(currentPosition, new BlockWrapper(currentBlock.getBlock(), Material.AIR, 0), currentIteration);
blockChangeTracker.put(currentPosition, new BlockWrapper(currentBlock.getBlock(), Material.AIR, 0), currentIteration);
} }
} }
} }
@ -220,14 +180,12 @@ public class ErodeBrush extends Brush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.erosion(v, this.currentPreset.getInverted()); this.erosion(v, this.currentPreset.getInverted());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.custom(ChatColor.AQUA + "Erosion minimum exposed faces set to " + this.currentPreset.getErosionFaces()); vm.custom(ChatColor.AQUA + "Erosion minimum exposed faces set to " + this.currentPreset.getErosionFaces());
@ -237,25 +195,19 @@ public class ErodeBrush extends Brush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{
JSAPResult result = this.parser.parse(Arrays.copyOfRange(par, 1, par.length)); JSAPResult result = this.parser.parse(Arrays.copyOfRange(par, 1, par.length));
if (sendHelpOrErrorMessageToPlayer(result, v.owner().getPlayer(), this.parser)) if (sendHelpOrErrorMessageToPlayer(result, v.owner().getPlayer(), this.parser)) {
{
return; return;
} }
if (result.getString("preset") != null) if (result.getString("preset") != null) {
{ try {
try
{
this.currentPreset = Preset.valueOf(result.getString("preset").toUpperCase()).getPreset(); this.currentPreset = Preset.valueOf(result.getString("preset").toUpperCase()).getPreset();
v.getVoxelMessage().brushMessage("Brush preset set to " + result.getString("preset")); v.getVoxelMessage().brushMessage("Brush preset set to " + result.getString("preset"));
return; return;
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception)
{
v.getVoxelMessage().brushMessage("No such preset."); v.getVoxelMessage().brushMessage("No such preset.");
return; return;
} }
@ -263,57 +215,51 @@ public class ErodeBrush extends Brush
ErosionPreset currentPresetBackup = this.currentPreset; ErosionPreset currentPresetBackup = this.currentPreset;
if (result.getObject("fill") != null) if (result.getObject("fill") != null) {
{
this.currentPreset = new ErosionPreset(this.currentPreset.getErosionFaces(), this.currentPreset.getErosionRecursion(), result.getInt("fill"), this.currentPreset.getFillRecursion()); this.currentPreset = new ErosionPreset(this.currentPreset.getErosionFaces(), this.currentPreset.getErosionRecursion(), result.getInt("fill"), this.currentPreset.getFillRecursion());
} }
if (result.getObject("erode") != null) if (result.getObject("erode") != null) {
{
this.currentPreset = new ErosionPreset(result.getInt("erode"), this.currentPreset.getErosionRecursion(), this.currentPreset.getFillFaces(), this.currentPreset.getFillRecursion()); this.currentPreset = new ErosionPreset(result.getInt("erode"), this.currentPreset.getErosionRecursion(), this.currentPreset.getFillFaces(), this.currentPreset.getFillRecursion());
} }
if (result.getObject("fillrecursion") != null) if (result.getObject("fillrecursion") != null) {
{
this.currentPreset = new ErosionPreset(this.currentPreset.getErosionFaces(), this.currentPreset.getErosionRecursion(), this.currentPreset.getFillFaces(), result.getInt("fillrecursion")); this.currentPreset = new ErosionPreset(this.currentPreset.getErosionFaces(), this.currentPreset.getErosionRecursion(), this.currentPreset.getFillFaces(), result.getInt("fillrecursion"));
} }
if (result.getObject("eroderecursion") != null) if (result.getObject("eroderecursion") != null) {
{
this.currentPreset = new ErosionPreset(this.currentPreset.getErosionFaces(), result.getInt("eroderecursion"), this.currentPreset.getFillFaces(), this.currentPreset.getFillRecursion()); this.currentPreset = new ErosionPreset(this.currentPreset.getErosionFaces(), result.getInt("eroderecursion"), this.currentPreset.getFillFaces(), this.currentPreset.getFillRecursion());
} }
if (!currentPreset.equals(currentPresetBackup)) if (!currentPreset.equals(currentPresetBackup)) {
{ if (currentPreset.getErosionFaces() != currentPresetBackup.getErosionFaces()) {
if (currentPreset.getErosionFaces() != currentPresetBackup.getErosionFaces())
{
v.sendMessage(ChatColor.AQUA + "Erosion faces set to: " + ChatColor.WHITE + currentPreset.getErosionFaces()); v.sendMessage(ChatColor.AQUA + "Erosion faces set to: " + ChatColor.WHITE + currentPreset.getErosionFaces());
} }
if (currentPreset.getFillFaces() != currentPresetBackup.getFillFaces()) if (currentPreset.getFillFaces() != currentPresetBackup.getFillFaces()) {
{
v.sendMessage(ChatColor.AQUA + "Fill faces set to: " + ChatColor.WHITE + currentPreset.getFillFaces()); v.sendMessage(ChatColor.AQUA + "Fill faces set to: " + ChatColor.WHITE + currentPreset.getFillFaces());
} }
if (currentPreset.getErosionRecursion() != currentPresetBackup.getErosionRecursion()) if (currentPreset.getErosionRecursion() != currentPresetBackup.getErosionRecursion()) {
{
v.sendMessage(ChatColor.AQUA + "Erosion recursions set to: " + ChatColor.WHITE + currentPreset.getErosionRecursion()); v.sendMessage(ChatColor.AQUA + "Erosion recursions set to: " + ChatColor.WHITE + currentPreset.getErosionRecursion());
} }
if (currentPreset.getFillRecursion() != currentPresetBackup.getFillRecursion()) if (currentPreset.getFillRecursion() != currentPresetBackup.getFillRecursion()) {
{
v.sendMessage(ChatColor.AQUA + "Fill recursions set to: " + ChatColor.WHITE + currentPreset.getFillRecursion()); v.sendMessage(ChatColor.AQUA + "Fill recursions set to: " + ChatColor.WHITE + currentPreset.getFillRecursion());
} }
} }
} }
@Override
public String getPermissionNode() {
return "voxelsniper.brush.erode";
}
/** /**
* @author MikeMatrix * @author MikeMatrix
*/ */
private enum Preset private enum Preset {
{
MELT(new ErosionPreset(2, 1, 5, 1)), FILL(new ErosionPreset(5, 1, 2, 1)), SMOOTH(new ErosionPreset(3, 1, 3, 1)), LIFT(new ErosionPreset(6, 0, 1, 1)), FLOATCLEAN(new ErosionPreset(6, 1, 6, 1)); MELT(new ErosionPreset(2, 1, 5, 1)), FILL(new ErosionPreset(5, 1, 2, 1)), SMOOTH(new ErosionPreset(3, 1, 3, 1)), LIFT(new ErosionPreset(6, 0, 1, 1)), FLOATCLEAN(new ErosionPreset(6, 1, 6, 1));
private ErosionPreset preset; private ErosionPreset preset;
Preset(final ErosionPreset preset) Preset(final ErosionPreset preset) {
{
this.preset = preset; this.preset = preset;
} }
@ -323,19 +269,14 @@ public class ErodeBrush extends Brush
* @param seperator Seperator for delimiting entries. * @param seperator Seperator for delimiting entries.
* @return * @return
*/ */
public static String getValuesString(String seperator) public static String getValuesString(String seperator) {
{
String valuesString = ""; String valuesString = "";
boolean delimiterHelper = true; boolean delimiterHelper = true;
for (final Preset preset : Preset.values()) for (final Preset preset : Preset.values()) {
{ if (delimiterHelper) {
if (delimiterHelper)
{
delimiterHelper = false; delimiterHelper = false;
} } else {
else
{
valuesString += seperator; valuesString += seperator;
} }
valuesString += preset.name(); valuesString += preset.name();
@ -343,8 +284,7 @@ public class ErodeBrush extends Brush
return valuesString; return valuesString;
} }
public ErosionPreset getPreset() public ErosionPreset getPreset() {
{
return this.preset; return this.preset;
} }
@ -354,28 +294,23 @@ public class ErodeBrush extends Brush
/** /**
* @author MikeMatrix * @author MikeMatrix
*/ */
private static final class BlockChangeTracker private static final class BlockChangeTracker {
{
private final Map<Integer, Map<Vector, BlockWrapper>> blockChanges; private final Map<Integer, Map<Vector, BlockWrapper>> blockChanges;
private final Map<Vector, BlockWrapper> flatChanges; private final Map<Vector, BlockWrapper> flatChanges;
private final AsyncWorld world; private final AsyncWorld world;
private int nextIterationId = 0; private int nextIterationId = 0;
public BlockChangeTracker(final AsyncWorld world) public BlockChangeTracker(final AsyncWorld world) {
{
this.blockChanges = new HashMap<>(); this.blockChanges = new HashMap<>();
this.flatChanges = new HashMap<>(); this.flatChanges = new HashMap<>();
this.world = world; this.world = world;
} }
public BlockWrapper get(final Vector position, final int iteration) public BlockWrapper get(final Vector position, final int iteration) {
{
BlockWrapper changedBlock = null; BlockWrapper changedBlock = null;
for (int i = iteration - 1; i >= 0; --i) for (int i = iteration - 1; i >= 0; --i) {
{ if (this.blockChanges.containsKey(i) && this.blockChanges.get(i).containsKey(position)) {
if (this.blockChanges.containsKey(i) && this.blockChanges.get(i).containsKey(position))
{
changedBlock = this.blockChanges.get(i).get(position); changedBlock = this.blockChanges.get(i).get(position);
return changedBlock; return changedBlock;
} }
@ -386,20 +321,16 @@ public class ErodeBrush extends Brush
return changedBlock; return changedBlock;
} }
public Collection<BlockWrapper> getAll() public Collection<BlockWrapper> getAll() {
{
return this.flatChanges.values(); return this.flatChanges.values();
} }
public int nextIteration() public int nextIteration() {
{
return this.nextIterationId++; return this.nextIterationId++;
} }
public void put(final Vector position, final BlockWrapper changedBlock, final int iteration) public void put(final Vector position, final BlockWrapper changedBlock, final int iteration) {
{ if (!this.blockChanges.containsKey(iteration)) {
if (!this.blockChanges.containsKey(iteration))
{
this.blockChanges.put(iteration, new HashMap<>()); this.blockChanges.put(iteration, new HashMap<>());
} }
@ -411,23 +342,20 @@ public class ErodeBrush extends Brush
/** /**
* @author MikeMatrix * @author MikeMatrix
*/ */
private static final class BlockWrapper private static final class BlockWrapper {
{
private final AsyncBlock block; private final AsyncBlock block;
private final Material material; private final Material material;
private final int data; private final int data;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public BlockWrapper(final AsyncBlock block) public BlockWrapper(final AsyncBlock block) {
{
this.block = block; this.block = block;
this.data = block.getPropertyId(); this.data = block.getPropertyId();
this.material = block.getType(); this.material = block.getType();
} }
public BlockWrapper(final AsyncBlock block, final Material material, final int data) public BlockWrapper(final AsyncBlock block, final Material material, final int data) {
{
this.block = block; this.block = block;
this.material = material; this.material = material;
this.data = data; this.data = data;
@ -436,32 +364,28 @@ public class ErodeBrush extends Brush
/** /**
* @return the block * @return the block
*/ */
public AsyncBlock getBlock() public AsyncBlock getBlock() {
{
return this.block; return this.block;
} }
/** /**
* @return the data * @return the data
*/ */
public int getPropertyId() public int getPropertyId() {
{
return this.data; return this.data;
} }
/** /**
* @return the material * @return the material
*/ */
public Material getMaterial() public Material getMaterial() {
{
return this.material; return this.material;
} }
/** /**
* @return if the block is Empty. * @return if the block is Empty.
*/ */
public boolean isEmpty() public boolean isEmpty() {
{
switch (material) { switch (material) {
case AIR: case AIR:
case CAVE_AIR: case CAVE_AIR:
@ -475,10 +399,8 @@ public class ErodeBrush extends Brush
/** /**
* @return if the block is a Liquid. * @return if the block is a Liquid.
*/ */
public boolean isLiquid() public boolean isLiquid() {
{ switch (this.material) {
switch (this.material)
{
case WATER: case WATER:
case LAVA: case LAVA:
return true; return true;
@ -492,15 +414,13 @@ public class ErodeBrush extends Brush
/** /**
* @author MikeMatrix * @author MikeMatrix
*/ */
private static final class ErosionPreset private static final class ErosionPreset {
{
private final int erosionFaces; private final int erosionFaces;
private final int erosionRecursion; private final int erosionRecursion;
private final int fillFaces; private final int fillFaces;
private final int fillRecursion; private final int fillRecursion;
public ErosionPreset(final int erosionFaces, final int erosionRecursion, final int fillFaces, final int fillRecursion) public ErosionPreset(final int erosionFaces, final int erosionRecursion, final int fillFaces, final int fillRecursion) {
{
this.erosionFaces = erosionFaces; this.erosionFaces = erosionFaces;
this.erosionRecursion = erosionRecursion; this.erosionRecursion = erosionRecursion;
this.fillFaces = fillFaces; this.fillFaces = fillFaces;
@ -508,16 +428,13 @@ public class ErodeBrush extends Brush
} }
@Override @Override
public int hashCode() public int hashCode() {
{
return Objects.hashCode(erosionFaces, erosionRecursion, fillFaces, fillRecursion); return Objects.hashCode(erosionFaces, erosionRecursion, fillFaces, fillRecursion);
} }
@Override @Override
public boolean equals(final Object obj) public boolean equals(final Object obj) {
{ if (obj instanceof ErosionPreset) {
if (obj instanceof ErosionPreset)
{
ErosionPreset other = (ErosionPreset) obj; ErosionPreset other = (ErosionPreset) obj;
return Objects.equal(this.erosionFaces, other.erosionFaces) && Objects.equal(this.erosionRecursion, other.erosionRecursion) && Objects.equal(this.fillFaces, other.fillFaces) && Objects.equal(this.fillRecursion, other.fillRecursion); return Objects.equal(this.erosionFaces, other.erosionFaces) && Objects.equal(this.erosionRecursion, other.erosionRecursion) && Objects.equal(this.fillFaces, other.fillFaces) && Objects.equal(this.fillRecursion, other.fillRecursion);
} }
@ -527,44 +444,33 @@ public class ErodeBrush extends Brush
/** /**
* @return the erosionFaces * @return the erosionFaces
*/ */
public int getErosionFaces() public int getErosionFaces() {
{
return this.erosionFaces; return this.erosionFaces;
} }
/** /**
* @return the erosionRecursion * @return the erosionRecursion
*/ */
public int getErosionRecursion() public int getErosionRecursion() {
{
return this.erosionRecursion; return this.erosionRecursion;
} }
/** /**
* @return the fillFaces * @return the fillFaces
*/ */
public int getFillFaces() public int getFillFaces() {
{
return this.fillFaces; return this.fillFaces;
} }
/** /**
* @return the fillRecursion * @return the fillRecursion
*/ */
public int getFillRecursion() public int getFillRecursion() {
{
return this.fillRecursion; return this.fillRecursion;
} }
public ErosionPreset getInverted() public ErosionPreset getInverted() {
{
return new ErosionPreset(this.fillFaces, this.fillRecursion, this.erosionFaces, this.erosionRecursion); return new ErosionPreset(this.fillFaces, this.fillRecursion, this.erosionFaces, this.erosionRecursion);
} }
} }
@Override
public String getPermissionNode()
{
return "voxelsniper.brush.erode";
}
} }

Datei anzeigen

@ -12,34 +12,27 @@ import org.bukkit.block.BlockFace;
* *
* @author psanker * @author psanker
*/ */
public class ExtrudeBrush extends Brush public class ExtrudeBrush extends Brush {
{
private double trueCircle; private double trueCircle;
/** /**
* *
*/ */
public ExtrudeBrush() public ExtrudeBrush() {
{
this.setName("Extrude"); this.setName("Extrude");
} }
private void extrudeUpOrDown(final SnipeData v, boolean isUp) private void extrudeUpOrDown(final SnipeData v, boolean isUp) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
Undo undo = new Undo(); Undo undo = new Undo();
for (int x = -brushSize; x <= brushSize; x++) for (int x = -brushSize; x <= brushSize; x++) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int z = -brushSize; z <= brushSize; z++) for (int z = -brushSize; z <= brushSize; z++) {
{ if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared) {
if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared)
{
final int direction = (isUp ? 1 : -1); final int direction = (isUp ? 1 : -1);
for (int y = 0; y < Math.abs(v.getVoxelHeight()); y++) for (int y = 0; y < Math.abs(v.getVoxelHeight()); y++) {
{
final int tempY = y * direction; final int tempY = y * direction;
undo = this.perform( undo = this.perform(
this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + tempY, this.getTargetBlock().getZ() + z), this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + tempY, this.getTargetBlock().getZ() + z),
@ -53,22 +46,17 @@ public class ExtrudeBrush extends Brush
v.owner().storeUndo(undo); v.owner().storeUndo(undo);
} }
private void extrudeNorthOrSouth(final SnipeData v, boolean isSouth) private void extrudeNorthOrSouth(final SnipeData v, boolean isSouth) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
Undo undo = new Undo(); Undo undo = new Undo();
for (int x = -brushSize; x <= brushSize; x++) for (int x = -brushSize; x <= brushSize; x++) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int y = -brushSize; y <= brushSize; y++) for (int y = -brushSize; y <= brushSize; y++) {
{ if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared) {
if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared)
{
final int direction = (isSouth) ? 1 : -1; final int direction = (isSouth) ? 1 : -1;
for (int z = 0; z < Math.abs(v.getVoxelHeight()); z++) for (int z = 0; z < Math.abs(v.getVoxelHeight()); z++) {
{
final int tempZ = z * direction; final int tempZ = z * direction;
undo = this.perform( undo = this.perform(
this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + tempZ), this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + tempZ),
@ -83,22 +71,17 @@ public class ExtrudeBrush extends Brush
v.owner().storeUndo(undo); v.owner().storeUndo(undo);
} }
private void extrudeEastOrWest(final SnipeData v, boolean isEast) private void extrudeEastOrWest(final SnipeData v, boolean isEast) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
Undo undo = new Undo(); Undo undo = new Undo();
for (int y = -brushSize; y <= brushSize; y++) for (int y = -brushSize; y <= brushSize; y++) {
{
final double ySquared = Math.pow(y, 2); final double ySquared = Math.pow(y, 2);
for (int z = -brushSize; z <= brushSize; z++) for (int z = -brushSize; z <= brushSize; z++) {
{ if ((ySquared + Math.pow(z, 2)) <= brushSizeSquared) {
if ((ySquared + Math.pow(z, 2)) <= brushSizeSquared)
{
final int direction = (isEast) ? 1 : -1; final int direction = (isEast) ? 1 : -1;
for (int x = 0; x < Math.abs(v.getVoxelHeight()); x++) for (int x = 0; x < Math.abs(v.getVoxelHeight()); x++) {
{
final int tempX = x * direction; final int tempX = x * direction;
undo = this.perform( undo = this.perform(
this.clampY(this.getTargetBlock().getX() + tempX, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z), this.clampY(this.getTargetBlock().getX() + tempX, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z),
@ -113,10 +96,8 @@ public class ExtrudeBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private Undo perform(final Block b1, final Block b2, final SnipeData v, final Undo undo) private Undo perform(final Block b1, final Block b2, final SnipeData v, final Undo undo) {
{ if (v.getVoxelList().contains(b1.getBlockData())) {
if (v.getVoxelList().contains(b1.getBlockData()))
{
undo.put(b2); undo.put(b2);
this.setBlockIdAt(b2.getZ(), b2.getX(), b2.getY(), this.getBlockIdAt(b1.getX(), b1.getY(), b1.getZ())); this.setBlockIdAt(b2.getZ(), b2.getX(), b2.getY(), this.getBlockIdAt(b1.getX(), b1.getY(), b1.getZ()));
this.clampY(b2.getX(), b2.getY(), b2.getZ()).setPropertyId(this.clampY(b1.getX(), b1.getY(), b1.getZ()).getPropertyId()); this.clampY(b2.getX(), b2.getY(), b2.getZ()).setPropertyId(this.clampY(b1.getX(), b1.getY(), b1.getZ()).getPropertyId());
@ -125,15 +106,12 @@ public class ExtrudeBrush extends Brush
return undo; return undo;
} }
private void selectExtrudeMethod(final SnipeData v, final BlockFace blockFace, final boolean towardsUser) private void selectExtrudeMethod(final SnipeData v, final BlockFace blockFace, final boolean towardsUser) {
{ if (blockFace == null || v.getVoxelHeight() == 0) {
if (blockFace == null || v.getVoxelHeight() == 0)
{
return; return;
} }
boolean tempDirection = towardsUser; boolean tempDirection = towardsUser;
switch (blockFace) switch (blockFace) {
{
case DOWN: case DOWN:
tempDirection = !towardsUser; tempDirection = !towardsUser;
case UP: case UP:
@ -155,20 +133,17 @@ public class ExtrudeBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.selectExtrudeMethod(v, this.getTargetBlock().getFace(this.getLastBlock()), false); this.selectExtrudeMethod(v, this.getTargetBlock().getFace(this.getLastBlock()), false);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.selectExtrudeMethod(v, this.getTargetBlock().getFace(this.getLastBlock()), true); this.selectExtrudeMethod(v, this.getTargetBlock().getFace(this.getLastBlock()), true);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.height(); vm.height();
@ -178,46 +153,33 @@ public class ExtrudeBrush extends Brush
} }
@Override @Override
public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
try try {
{ if (parameter.equalsIgnoreCase("info")) {
if (parameter.equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Extrude brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Extrude brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b ex true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b ex false will switch back. (false is default)"); v.sendMessage(ChatColor.AQUA + "/b ex true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b ex false will switch back. (false is default)");
return; return;
} } else if (parameter.startsWith("true")) {
else if (parameter.startsWith("true"))
{
this.trueCircle = 0.5; this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON."); v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
} } else if (parameter.startsWith("false")) {
else if (parameter.startsWith("false"))
{
this.trueCircle = 0; this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the \"info\" parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the \"info\" parameter to display parameter info.");
return; return;
} }
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "Incorrect parameter \"" + parameter + "\"; use the \"info\" parameter."); v.sendMessage(ChatColor.RED + "Incorrect parameter \"" + parameter + "\"; use the \"info\" parameter.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.extrude"; return "voxelsniper.brush.extrude";
} }
} }

Datei anzeigen

@ -11,8 +11,7 @@ import org.bukkit.block.Block;
/** /**
* @author Voxel * @author Voxel
*/ */
public class FillDownBrush extends PerformBrush public class FillDownBrush extends PerformBrush {
{
private double trueCircle = 0; private double trueCircle = 0;
private boolean fillLiquid = true; private boolean fillLiquid = true;
private boolean fromExisting = false; private boolean fromExisting = false;
@ -20,51 +19,43 @@ public class FillDownBrush extends PerformBrush
/** /**
* *
*/ */
public FillDownBrush() public FillDownBrush() {
{
this.setName("Fill Down"); this.setName("Fill Down");
} }
private void fillDown(final SnipeData v, final Block b) private void fillDown(final SnipeData v, final Block b) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
final Block targetBlock = this.getTargetBlock(); final Block targetBlock = this.getTargetBlock();
for (int x = -brushSize; x <= brushSize; x++) for (int x = -brushSize; x <= brushSize; x++) {
{
final double currentXSquared = Math.pow(x, 2); final double currentXSquared = Math.pow(x, 2);
for (int z = -brushSize; z <= brushSize; z++) for (int z = -brushSize; z <= brushSize; z++) {
{ if (currentXSquared + Math.pow(z, 2) <= brushSizeSquared) {
if (currentXSquared + Math.pow(z, 2) <= brushSizeSquared) int y = 0;
{ boolean found = false;
int y = 0; if (this.fromExisting) {
boolean found = false; for (y = -v.getVoxelHeight(); y < v.getVoxelHeight(); y++) {
if(this.fromExisting) { final Block currentBlock = this.getWorld().getBlockAt(
for(y = -v.getVoxelHeight(); y < v.getVoxelHeight(); y++) { targetBlock.getX() + x,
final Block currentBlock = this.getWorld().getBlockAt( targetBlock.getY() + y,
targetBlock.getX() + x, targetBlock.getZ() + z);
targetBlock.getY() + y, if (!currentBlock.isEmpty()) {
targetBlock.getZ() + z); found = true;
if(!currentBlock.isEmpty()) { break;
found = true; }
break; }
} if (!found) continue;
} y--;
if(!found) continue; }
y--; for (; y >= -targetBlock.getY(); --y) {
}
for (; y >= -targetBlock.getY(); --y)
{
final AsyncBlock currentBlock = this.getWorld().getBlockAt( final AsyncBlock currentBlock = this.getWorld().getBlockAt(
targetBlock.getX() + x, targetBlock.getX() + x,
targetBlock.getY() + y, targetBlock.getY() + y,
targetBlock.getZ() + z); targetBlock.getZ() + z);
if (currentBlock.isEmpty() || (fillLiquid && currentBlock.isLiquid())) if (currentBlock.isEmpty() || (fillLiquid && currentBlock.isLiquid())) {
{
this.current.perform(currentBlock); this.current.perform(currentBlock);
} else } else {
{
break; break;
} }
} }
@ -76,31 +67,25 @@ public class FillDownBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.fillDown(v, this.getTargetBlock()); this.fillDown(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.fillDown(v, this.getLastBlock()); this.fillDown(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++) if (par[i].equalsIgnoreCase("info")) {
{
if (par[i].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Fill Down Parameters:"); v.sendMessage(ChatColor.GOLD + "Fill Down Parameters:");
v.sendMessage(ChatColor.AQUA + "/b fd true -- will use a true circle algorithm."); v.sendMessage(ChatColor.AQUA + "/b fd true -- will use a true circle algorithm.");
v.sendMessage(ChatColor.AQUA + "/b fd false -- will switch back. (Default)"); v.sendMessage(ChatColor.AQUA + "/b fd false -- will switch back. (Default)");
@ -108,43 +93,30 @@ public class FillDownBrush extends PerformBrush
v.sendMessage(ChatColor.AQUA + "/b fd all -- Fills into liquids as well. (Default)"); v.sendMessage(ChatColor.AQUA + "/b fd all -- Fills into liquids as well. (Default)");
v.sendMessage(ChatColor.AQUA + "/b fd -e -- Fills into only existing blocks. (Toggle)"); v.sendMessage(ChatColor.AQUA + "/b fd -e -- Fills into only existing blocks. (Toggle)");
return; return;
} } else if (par[i].equalsIgnoreCase("true")) {
else if (par[i].equalsIgnoreCase("true"))
{
this.trueCircle = 0.5; this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON."); v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
} } else if (par[i].equalsIgnoreCase("false")) {
else if (par[i].equalsIgnoreCase("false"))
{
this.trueCircle = 0; this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} } else if (par[i].equalsIgnoreCase("all")) {
else if (par[i].equalsIgnoreCase("all"))
{
this.fillLiquid = true; this.fillLiquid = true;
v.sendMessage(ChatColor.AQUA + "Now filling liquids as well as air."); v.sendMessage(ChatColor.AQUA + "Now filling liquids as well as air.");
} } else if (par[i].equalsIgnoreCase("some")) {
else if (par[i].equalsIgnoreCase("some"))
{
this.fillLiquid = false; this.fillLiquid = false;
v.setReplaceId(BlockTypes.AIR.getInternalId()); v.setReplaceId(BlockTypes.AIR.getInternalId());
v.sendMessage(ChatColor.AQUA + "Now only filling air."); v.sendMessage(ChatColor.AQUA + "Now only filling air.");
} } else if (par[i].equalsIgnoreCase("-e")) {
else if (par[i].equalsIgnoreCase("-e")) this.fromExisting = !this.fromExisting;
{ v.sendMessage(ChatColor.AQUA + "Now filling down from " + ((this.fromExisting) ? "existing" : "all") + " blocks.");
this.fromExisting = !this.fromExisting; } else {
v.sendMessage(ChatColor.AQUA + "Now filling down from " + ((this.fromExisting) ? "existing" : "all") + " blocks.");
}
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.filldown"; return "voxelsniper.brush.filldown";
} }
} }

Datei anzeigen

@ -4,14 +4,12 @@ import com.boydti.fawe.bukkit.wrapper.AsyncChunk;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Material; import org.bukkit.Material;
/** /**
* @author GavJenks * @author GavJenks
*/ */
public class FlatOceanBrush extends Brush public class FlatOceanBrush extends Brush {
{
private static final int DEFAULT_WATER_LEVEL = 29; private static final int DEFAULT_WATER_LEVEL = 29;
private static final int DEFAULT_FLOOR_LEVEL = 8; private static final int DEFAULT_FLOOR_LEVEL = 8;
private int waterLevel = DEFAULT_WATER_LEVEL; private int waterLevel = DEFAULT_WATER_LEVEL;
@ -20,30 +18,20 @@ public class FlatOceanBrush extends Brush
/** /**
* *
*/ */
public FlatOceanBrush() public FlatOceanBrush() {
{
this.setName("FlatOcean"); this.setName("FlatOcean");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void flatOcean(final AsyncChunk chunk) private void flatOcean(final AsyncChunk chunk) {
{ for (int x = 0; x < CHUNK_SIZE; x++) {
for (int x = 0; x < CHUNK_SIZE; x++) for (int z = 0; z < CHUNK_SIZE; z++) {
{ for (int y = 0; y < chunk.getWorld().getMaxHeight(); y++) {
for (int z = 0; z < CHUNK_SIZE; z++) if (y <= this.floorLevel) {
{
for (int y = 0; y < chunk.getWorld().getMaxHeight(); y++)
{
if (y <= this.floorLevel)
{
chunk.getBlock(x, y, z).setType(Material.DIRT); chunk.getBlock(x, y, z).setType(Material.DIRT);
} } else if (y <= this.waterLevel) {
else if (y <= this.waterLevel)
{
chunk.getBlock(x, y, z).setType(Material.WATER); chunk.getBlock(x, y, z).setType(Material.WATER);
} } else {
else
{
chunk.getBlock(x, y, z).setType(Material.AIR); chunk.getBlock(x, y, z).setType(Material.AIR);
} }
} }
@ -52,14 +40,12 @@ public class FlatOceanBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.flatOcean(this.getWorld().getChunkAt(this.getTargetBlock())); this.flatOcean(this.getWorld().getChunkAt(this.getTargetBlock()));
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.flatOcean(this.getWorld().getChunkAt(this.getTargetBlock())); this.flatOcean(this.getWorld().getChunkAt(this.getTargetBlock()));
this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX() + CHUNK_SIZE, 1, this.getTargetBlock().getZ()))); this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX() + CHUNK_SIZE, 1, this.getTargetBlock().getZ())));
this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX() + CHUNK_SIZE, 1, this.getTargetBlock().getZ() + CHUNK_SIZE))); this.flatOcean(this.getWorld().getChunkAt(this.clampY(this.getTargetBlock().getX() + CHUNK_SIZE, 1, this.getTargetBlock().getZ() + CHUNK_SIZE)));
@ -72,8 +58,7 @@ public class FlatOceanBrush extends Brush
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.RED + "THIS BRUSH DOES NOT UNDO"); vm.custom(ChatColor.RED + "THIS BRUSH DOES NOT UNDO");
vm.custom(ChatColor.GREEN + "Water level set to " + this.waterLevel); vm.custom(ChatColor.GREEN + "Water level set to " + this.waterLevel);
@ -81,35 +66,26 @@ public class FlatOceanBrush extends Brush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GREEN + "yo[number] to set the Level to which the water will rise."); v.sendMessage(ChatColor.GREEN + "yo[number] to set the Level to which the water will rise.");
v.sendMessage(ChatColor.GREEN + "yl[number] to set the Level to which the ocean floor will rise."); v.sendMessage(ChatColor.GREEN + "yl[number] to set the Level to which the ocean floor will rise.");
} }
if (parameter.startsWith("yo")) if (parameter.startsWith("yo")) {
{
int newWaterLevel = Integer.parseInt(parameter.replace("yo", "")); int newWaterLevel = Integer.parseInt(parameter.replace("yo", ""));
if (newWaterLevel < this.floorLevel) if (newWaterLevel < this.floorLevel) {
{
newWaterLevel = this.floorLevel + 1; newWaterLevel = this.floorLevel + 1;
} }
this.waterLevel = newWaterLevel; this.waterLevel = newWaterLevel;
v.sendMessage(ChatColor.GREEN + "Water Level set to " + this.waterLevel); v.sendMessage(ChatColor.GREEN + "Water Level set to " + this.waterLevel);
} } else if (parameter.startsWith("yl")) {
else if (parameter.startsWith("yl"))
{
int newFloorLevel = Integer.parseInt(parameter.replace("yl", "")); int newFloorLevel = Integer.parseInt(parameter.replace("yl", ""));
if (newFloorLevel > this.waterLevel) if (newFloorLevel > this.waterLevel) {
{
newFloorLevel = this.waterLevel - 1; newFloorLevel = this.waterLevel - 1;
if (newFloorLevel == 0) if (newFloorLevel == 0) {
{
newFloorLevel = 1; newFloorLevel = 1;
this.waterLevel = 2; this.waterLevel = 2;
} }
@ -121,8 +97,7 @@ public class FlatOceanBrush extends Brush
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.flatocean"; return "voxelsniper.brush.flatocean";
} }
} }

Datei anzeigen

@ -1,18 +1,17 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import java.util.ArrayList;
import java.util.Random;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import java.util.ArrayList;
import java.util.Random;
// Proposal: Use /v and /vr for leave and wood material // or two more parameters -- Monofraps // Proposal: Use /v and /vr for leave and wood material // or two more parameters -- Monofraps
/** /**
@ -20,8 +19,7 @@ import org.bukkit.block.Block;
* *
* @author Ghost8700 @ Voxel * @author Ghost8700 @ Voxel
*/ */
public class GenerateTreeBrush extends Brush public class GenerateTreeBrush extends Brush {
{
// Tree Variables. // Tree Variables.
private Random randGenerator = new Random(); private Random randGenerator = new Random();
private ArrayList<Block> branchBlocks = new ArrayList<>(); private ArrayList<Block> branchBlocks = new ArrayList<>();
@ -50,8 +48,7 @@ public class GenerateTreeBrush extends Brush
/** /**
* *
*/ */
public GenerateTreeBrush() public GenerateTreeBrush() {
{
this.setName("Generate Tree"); this.setName("Generate Tree");
} }
@ -85,8 +82,7 @@ public class GenerateTreeBrush extends Brush
// Branch Creation based on direction chosen from the parameters passed. // Branch Creation based on direction chosen from the parameters passed.
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void branchCreate(final int xDirection, final int zDirection) private void branchCreate(final int xDirection, final int zDirection) {
{
// Sets branch origin. // Sets branch origin.
final int originX = blockPositionX; final int originX = blockPositionX;
@ -98,28 +94,23 @@ public class GenerateTreeBrush extends Brush
final int zPreference = this.randGenerator.nextInt(60) + 20; final int zPreference = this.randGenerator.nextInt(60) + 20;
// Iterates according to branch length. // Iterates according to branch length.
for (int r = 0; r < this.branchLength; r++) for (int r = 0; r < this.branchLength; r++) {
{
// Alters direction according to preferences. // Alters direction according to preferences.
if (this.randGenerator.nextInt(100) < xPreference) if (this.randGenerator.nextInt(100) < xPreference) {
{
blockPositionX = blockPositionX + 1 * xDirection; blockPositionX = blockPositionX + 1 * xDirection;
} }
if (this.randGenerator.nextInt(100) < zPreference) if (this.randGenerator.nextInt(100) < zPreference) {
{
blockPositionZ = blockPositionZ + 1 * zDirection; blockPositionZ = blockPositionZ + 1 * zDirection;
} }
// 50% chance to increase elevation every second block. // 50% chance to increase elevation every second block.
if (Math.abs(r % 2) == 1) if (Math.abs(r % 2) == 1) {
{
blockPositionY = blockPositionY + this.randGenerator.nextInt(2); blockPositionY = blockPositionY + this.randGenerator.nextInt(2);
} }
// Add block to undo function. // Add block to undo function.
if (!isLog(this.getBlockType(blockPositionX, blockPositionY, blockPositionZ))) if (!isLog(this.getBlockType(blockPositionX, blockPositionY, blockPositionZ))) {
{
this.undo.put(this.clampY(blockPositionX, blockPositionY, blockPositionZ)); this.undo.put(this.clampY(blockPositionX, blockPositionY, blockPositionZ));
} }
@ -135,8 +126,7 @@ public class GenerateTreeBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void leafNodeCreate() private void leafNodeCreate() {
{
// Generates the node size. // Generates the node size.
final int nodeRadius = this.randGenerator.nextInt(this.nodeMax - this.nodeMin + 1) + this.nodeMin; final int nodeRadius = this.randGenerator.nextInt(this.nodeMax - this.nodeMin + 1) + this.nodeMin;
final double bSquared = Math.pow(nodeRadius + 0.5, 2); final double bSquared = Math.pow(nodeRadius + 0.5, 2);
@ -145,105 +135,77 @@ public class GenerateTreeBrush extends Brush
blockPositionY = blockPositionY - 2; blockPositionY = blockPositionY - 2;
for (int z = nodeRadius; z >= 0; z--) for (int z = nodeRadius; z >= 0; z--) {
{
final double zSquared = Math.pow(z, 2); final double zSquared = Math.pow(z, 2);
for (int x = nodeRadius; x >= 0; x--) for (int x = nodeRadius; x >= 0; x--) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int y = nodeRadius; y >= 0; y--) for (int y = nodeRadius; y >= 0; y--) {
{ if ((xSquared + Math.pow(y, 2) + zSquared) <= bSquared) {
if ((xSquared + Math.pow(y, 2) + zSquared) <= bSquared)
{
// Chance to skip creation of a block. // Chance to skip creation of a block.
if (this.randGenerator.nextInt(100) >= 30) if (this.randGenerator.nextInt(100) >= 30) {
{
// If block is Air, create a leaf block. // If block is Air, create a leaf block.
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ + z).isEmpty()) if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ + z).isEmpty()) {
{
// Adds block to undo function. // Adds block to undo function.
if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY + y, blockPositionZ + z))) if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY + y, blockPositionZ + z))) {
{
this.undo.put(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ + z)); this.undo.put(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ + z));
} }
// Creates block. // Creates block.
this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ + z).setType(this.leafType); this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ + z).setType(this.leafType);
} }
} }
if (this.randGenerator.nextInt(100) >= 30) if (this.randGenerator.nextInt(100) >= 30) {
{ if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ - z).isEmpty()) {
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ - z).isEmpty()) if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY + y, blockPositionZ - z))) {
{
if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY + y, blockPositionZ - z)))
{
this.undo.put(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ - z)); this.undo.put(this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ - z));
} }
this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ - z).setType(this.leafType); this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ - z).setType(this.leafType);
} }
} }
if (this.randGenerator.nextInt(100) >= 30) if (this.randGenerator.nextInt(100) >= 30) {
{ if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY + y, blockPositionZ + z).isEmpty()) {
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY + y, blockPositionZ + z).isEmpty()) if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY + y, blockPositionZ + z))) {
{
if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY + y, blockPositionZ + z)))
{
this.undo.put(this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ + z)); this.undo.put(this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ + z));
} }
this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ + z).setType(this.leafType); this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ + z).setType(this.leafType);
} }
} }
if (this.randGenerator.nextInt(100) >= 30) if (this.randGenerator.nextInt(100) >= 30) {
{ if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY + y, blockPositionZ - z).isEmpty()) {
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY + y, blockPositionZ - z).isEmpty()) if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY + y, blockPositionZ - z))) {
{
if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY + y, blockPositionZ - z)))
{
this.undo.put(this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ - z)); this.undo.put(this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ - z));
} }
this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ - z).setType(this.leafType); this.clampY(blockPositionX - x, blockPositionY + y, blockPositionZ - z).setType(this.leafType);
} }
} }
if (this.randGenerator.nextInt(100) >= 30) if (this.randGenerator.nextInt(100) >= 30) {
{ if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY - y, blockPositionZ + z).isEmpty()) {
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY - y, blockPositionZ + z).isEmpty()) if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY - y, blockPositionZ + z))) {
{
if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY - y, blockPositionZ + z)))
{
this.undo.put(this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ + z)); this.undo.put(this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ + z));
} }
this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ + z).setType(this.leafType); this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ + z).setType(this.leafType);
} }
} }
if (this.randGenerator.nextInt(100) >= 30) if (this.randGenerator.nextInt(100) >= 30) {
{ if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY - y, blockPositionZ - z).isEmpty()) {
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY - y, blockPositionZ - z).isEmpty()) if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY - y, blockPositionZ - z))) {
{
if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY - y, blockPositionZ - z)))
{
this.undo.put(this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ - z)); this.undo.put(this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ - z));
} }
this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ - z).setType(this.leafType); this.clampY(blockPositionX + x, blockPositionY - y, blockPositionZ - z).setType(this.leafType);
} }
} }
if (this.randGenerator.nextInt(100) >= 30) if (this.randGenerator.nextInt(100) >= 30) {
{ if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY - y, blockPositionZ + z).isEmpty()) {
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY - y, blockPositionZ + z).isEmpty()) if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY - y, blockPositionZ + z))) {
{
if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY - y, blockPositionZ + z)))
{
this.undo.put(this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ + z)); this.undo.put(this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ + z));
} }
this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ + z).setType(this.leafType); this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ + z).setType(this.leafType);
} }
} }
if (this.randGenerator.nextInt(100) >= 30) if (this.randGenerator.nextInt(100) >= 30) {
{ if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY - y, blockPositionZ - z).isEmpty()) {
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY - y, blockPositionZ - z).isEmpty()) if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY - y, blockPositionZ - z))) {
{
if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY - y, blockPositionZ - z)))
{
this.undo.put(this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ - z)); this.undo.put(this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ - z));
} }
this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ - z).setType(this.leafType); this.clampY(blockPositionX - x, blockPositionY - y, blockPositionZ - z).setType(this.leafType);
@ -262,8 +224,7 @@ public class GenerateTreeBrush extends Brush
* @param zDirection * @param zDirection
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void rootCreate(final int xDirection, final int zDirection) private void rootCreate(final int xDirection, final int zDirection) {
{
// Sets Origin. // Sets Origin.
final int originX = blockPositionX; final int originX = blockPositionX;
final int originY = blockPositionY; final int originY = blockPositionY;
@ -276,11 +237,9 @@ public class GenerateTreeBrush extends Brush
// Loops for each root to be created. // Loops for each root to be created.
for (int i = 0; i < roots; i++) for (int i = 0; i < roots; i++) {
{
// Pushes the root'world starting point out from the center of the tree. // Pushes the root'world starting point out from the center of the tree.
for (int t = 0; t < this.thickness - 1; t++) for (int t = 0; t < this.thickness - 1; t++) {
{
blockPositionX = blockPositionX + xDirection; blockPositionX = blockPositionX + xDirection;
blockPositionZ = blockPositionZ + zDirection; blockPositionZ = blockPositionZ + zDirection;
} }
@ -289,57 +248,44 @@ public class GenerateTreeBrush extends Brush
final int xPreference = this.randGenerator.nextInt(30) + 40; final int xPreference = this.randGenerator.nextInt(30) + 40;
final int zPreference = this.randGenerator.nextInt(30) + 40; final int zPreference = this.randGenerator.nextInt(30) + 40;
for (int j = 0; j < this.rootLength; j++) for (int j = 0; j < this.rootLength; j++) {
{
// For the purposes of this algorithm, logs aren't considered solid. // For the purposes of this algorithm, logs aren't considered solid.
// If not solid then... // If not solid then...
// Save for undo function // Save for undo function
if (!isLog(this.getBlockType(blockPositionX, blockPositionY, blockPositionZ))) if (!isLog(this.getBlockType(blockPositionX, blockPositionY, blockPositionZ))) {
{
this.undo.put(this.clampY(blockPositionX, blockPositionY, blockPositionZ)); this.undo.put(this.clampY(blockPositionX, blockPositionY, blockPositionZ));
// Place log block. // Place log block.
this.clampY(blockPositionX, blockPositionY, blockPositionZ).setType(this.woodType); this.clampY(blockPositionX, blockPositionY, blockPositionZ).setType(this.woodType);
} } else {
else
{
// If solid then... // If solid then...
// End loop // End loop
break; break;
} }
// Checks is block below is solid // Checks is block below is solid
if (this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).isEmpty() || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.WATER || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.SNOW || isLog(this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType())) if (this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).isEmpty() || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.WATER || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.SNOW || isLog(this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType())) {
{
// Mos down if solid. // Mos down if solid.
blockPositionY = blockPositionY - 1; blockPositionY = blockPositionY - 1;
if (this.rootFloat) if (this.rootFloat) {
{ if (this.randGenerator.nextInt(100) < xPreference) {
if (this.randGenerator.nextInt(100) < xPreference)
{
blockPositionX = blockPositionX + xDirection; blockPositionX = blockPositionX + xDirection;
} }
if (this.randGenerator.nextInt(100) < zPreference) if (this.randGenerator.nextInt(100) < zPreference) {
{
blockPositionZ = blockPositionZ + zDirection; blockPositionZ = blockPositionZ + zDirection;
} }
} }
} } else {
else
{
// If solid then move. // If solid then move.
if (this.randGenerator.nextInt(100) < xPreference) if (this.randGenerator.nextInt(100) < xPreference) {
{
blockPositionX = blockPositionX + xDirection; blockPositionX = blockPositionX + xDirection;
} }
if (this.randGenerator.nextInt(100) < zPreference) if (this.randGenerator.nextInt(100) < zPreference) {
{
blockPositionZ = blockPositionZ + zDirection; blockPositionZ = blockPositionZ + zDirection;
} }
// Checks if new location is solid, if not then move down. // Checks if new location is solid, if not then move down.
if (this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).isEmpty() || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.WATER || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.SNOW || isLog(this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType())) if (this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).isEmpty() || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.WATER || this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType() == Material.SNOW || isLog(this.clampY(blockPositionX, blockPositionY - 1, blockPositionZ).getType())) {
{
blockPositionY = blockPositionY - 1; blockPositionY = blockPositionY - 1;
} }
} }
@ -353,8 +299,7 @@ public class GenerateTreeBrush extends Brush
} }
} }
private void rootGen() private void rootGen() {
{
// Quadrant 1 // Quadrant 1
this.rootCreate(1, 1); this.rootCreate(1, 1);
@ -369,50 +314,38 @@ public class GenerateTreeBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void trunkCreate() private void trunkCreate() {
{
// Creates true circle discs of the set size using the wood type selected. // Creates true circle discs of the set size using the wood type selected.
final double bSquared = Math.pow(this.thickness + 0.5, 2); final double bSquared = Math.pow(this.thickness + 0.5, 2);
for (int x = this.thickness; x >= 0; x--) for (int x = this.thickness; x >= 0; x--) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int z = this.thickness; z >= 0; z--) for (int z = this.thickness; z >= 0; z--) {
{ if ((xSquared + Math.pow(z, 2)) <= bSquared) {
if ((xSquared + Math.pow(z, 2)) <= bSquared)
{
// If block is air, then create a block. // If block is air, then create a block.
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY, blockPositionZ + z).isEmpty()) if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY, blockPositionZ + z).isEmpty()) {
{
// Adds block to undo function. // Adds block to undo function.
if (!isLog(this.getBlockType(blockPositionX + x, blockPositionY, blockPositionZ + z))) if (!isLog(this.getBlockType(blockPositionX + x, blockPositionY, blockPositionZ + z))) {
{
this.undo.put(this.clampY(blockPositionX + x, blockPositionY, blockPositionZ + z)); this.undo.put(this.clampY(blockPositionX + x, blockPositionY, blockPositionZ + z));
} }
// Creates block. // Creates block.
this.clampY(blockPositionX + x, blockPositionY, blockPositionZ + z).setType(this.woodType); this.clampY(blockPositionX + x, blockPositionY, blockPositionZ + z).setType(this.woodType);
} }
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY, blockPositionZ - z).isEmpty()) if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY, blockPositionZ - z).isEmpty()) {
{ if (!isLog(this.getBlockType(blockPositionX + x, blockPositionY, blockPositionZ - z))) {
if (!isLog(this.getBlockType(blockPositionX + x, blockPositionY, blockPositionZ - z)))
{
this.undo.put(this.clampY(blockPositionX + x, blockPositionY, blockPositionZ - z)); this.undo.put(this.clampY(blockPositionX + x, blockPositionY, blockPositionZ - z));
} }
this.clampY(blockPositionX + x, blockPositionY, blockPositionZ - z).setType(this.woodType); this.clampY(blockPositionX + x, blockPositionY, blockPositionZ - z).setType(this.woodType);
} }
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY, blockPositionZ + z).isEmpty()) if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY, blockPositionZ + z).isEmpty()) {
{ if (!isLog(this.getBlockType(blockPositionX - x, blockPositionY, blockPositionZ + z))) {
if (!isLog(this.getBlockType(blockPositionX - x, blockPositionY, blockPositionZ + z)))
{
this.undo.put(this.clampY(blockPositionX - x, blockPositionY, blockPositionZ + z)); this.undo.put(this.clampY(blockPositionX - x, blockPositionY, blockPositionZ + z));
} }
this.clampY(blockPositionX - x, blockPositionY, blockPositionZ + z).setType(this.woodType); this.clampY(blockPositionX - x, blockPositionY, blockPositionZ + z).setType(this.woodType);
} }
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY, blockPositionZ - z).isEmpty()) if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY, blockPositionZ - z).isEmpty()) {
{ if (!isLog(this.getBlockType(blockPositionX - x, blockPositionY, blockPositionZ - z))) {
if (!isLog(this.getBlockType(blockPositionX - x, blockPositionY, blockPositionZ - z)))
{
this.undo.put(this.clampY(blockPositionX - x, blockPositionY, blockPositionZ - z)); this.undo.put(this.clampY(blockPositionX - x, blockPositionY, blockPositionZ - z));
} }
this.clampY(blockPositionX - x, blockPositionY, blockPositionZ - z).setType(this.woodType); this.clampY(blockPositionX - x, blockPositionY, blockPositionZ - z).setType(this.woodType);
@ -426,8 +359,7 @@ public class GenerateTreeBrush extends Brush
* *
* Code Concerning Trunk Generation * Code Concerning Trunk Generation
*/ */
private void trunkGen() private void trunkGen() {
{
// Sets Origin // Sets Origin
final int originX = blockPositionX; final int originX = blockPositionX;
final int originY = blockPositionY; final int originY = blockPositionY;
@ -442,38 +374,30 @@ public class GenerateTreeBrush extends Brush
// Sets direction. // Sets direction.
int xDirection = 1; int xDirection = 1;
if (this.randGenerator.nextInt(100) < 50) if (this.randGenerator.nextInt(100) < 50) {
{
xDirection = -1; xDirection = -1;
} }
int zDirection = 1; int zDirection = 1;
if (this.randGenerator.nextInt(100) < 50) if (this.randGenerator.nextInt(100) < 50) {
{
zDirection = -1; zDirection = -1;
} }
// Generates a height for trunk. // Generates a height for trunk.
int height = this.randGenerator.nextInt(this.heightMaximum - this.heightMininmum + 1) + this.heightMininmum; int height = this.randGenerator.nextInt(this.heightMaximum - this.heightMininmum + 1) + this.heightMininmum;
for (int p = 0; p < height; p++) for (int p = 0; p < height; p++) {
{ if (p > 3) {
if (p > 3) if (this.randGenerator.nextInt(100) <= this.twistChance) {
{
if (this.randGenerator.nextInt(100) <= this.twistChance)
{
xDirection *= -1; xDirection *= -1;
} }
if (this.randGenerator.nextInt(100) <= this.twistChance) if (this.randGenerator.nextInt(100) <= this.twistChance) {
{
zDirection *= -1; zDirection *= -1;
} }
if (this.randGenerator.nextInt(100) < xPreference) if (this.randGenerator.nextInt(100) < xPreference) {
{
blockPositionX += xDirection; blockPositionX += xDirection;
} }
if (this.randGenerator.nextInt(100) < zPreference) if (this.randGenerator.nextInt(100) < zPreference) {
{
blockPositionZ += zDirection; blockPositionZ += zDirection;
} }
} }
@ -505,38 +429,30 @@ public class GenerateTreeBrush extends Brush
// Sets direction. // Sets direction.
xDirection = 1; xDirection = 1;
if (this.randGenerator.nextInt(100) < 50) if (this.randGenerator.nextInt(100) < 50) {
{
xDirection = -1; xDirection = -1;
} }
zDirection = 1; zDirection = 1;
if (this.randGenerator.nextInt(100) < 50) if (this.randGenerator.nextInt(100) < 50) {
{
zDirection = -1; zDirection = -1;
} }
// Generates a height for trunk. // Generates a height for trunk.
height = this.randGenerator.nextInt(this.heightMaximum - this.heightMininmum + 1) + this.heightMininmum; height = this.randGenerator.nextInt(this.heightMaximum - this.heightMininmum + 1) + this.heightMininmum;
if (height > 4) if (height > 4) {
{ for (int p = 0; p < height; p++) {
for (int p = 0; p < height; p++) if (this.randGenerator.nextInt(100) <= this.twistChance) {
{
if (this.randGenerator.nextInt(100) <= this.twistChance)
{
xDirection *= -1; xDirection *= -1;
} }
if (this.randGenerator.nextInt(100) <= this.twistChance) if (this.randGenerator.nextInt(100) <= this.twistChance) {
{
zDirection *= -1; zDirection *= -1;
} }
if (this.randGenerator.nextInt(100) < xPreference) if (this.randGenerator.nextInt(100) < xPreference) {
{
blockPositionX = blockPositionX + 1 * xDirection; blockPositionX = blockPositionX + 1 * xDirection;
} }
if (this.randGenerator.nextInt(100) < zPreference) if (this.randGenerator.nextInt(100) < zPreference) {
{
blockPositionZ = blockPositionZ + 1 * zDirection; blockPositionZ = blockPositionZ + 1 * zDirection;
} }
@ -556,8 +472,7 @@ public class GenerateTreeBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.undo = new Undo(); this.undo = new Undo();
this.branchBlocks.clear(); this.branchBlocks.clear();
@ -575,8 +490,7 @@ public class GenerateTreeBrush extends Brush
// Each branch block was saved in an array. This is now fed through an array. // Each branch block was saved in an array. This is now fed through an array.
// This array takes each branch block and constructs a leaf node around it. // This array takes each branch block and constructs a leaf node around it.
for (final Block block : this.branchBlocks) for (final Block block : this.branchBlocks) {
{
blockPositionX = block.getX(); blockPositionX = block.getX();
blockPositionY = block.getY(); blockPositionY = block.getY();
blockPositionZ = block.getZ(); blockPositionZ = block.getZ();
@ -589,28 +503,22 @@ public class GenerateTreeBrush extends Brush
// The Powder currently does nothing extra. // The Powder currently does nothing extra.
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.arrow(v); this.arrow(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
try try {
{ if (parameter.equalsIgnoreCase("info")) {
if (parameter.equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "This brush takes the following parameters:"); v.sendMessage(ChatColor.GOLD + "This brush takes the following parameters:");
v.sendMessage(ChatColor.AQUA + "lt# - leaf type (data value)"); v.sendMessage(ChatColor.AQUA + "lt# - leaf type (data value)");
v.sendMessage(ChatColor.AQUA + "wt# - wood type (data value)"); v.sendMessage(ChatColor.AQUA + "wt# - wood type (data value)");
@ -624,8 +532,7 @@ public class GenerateTreeBrush extends Brush
return; return;
} }
if (parameter.equalsIgnoreCase("info2")) if (parameter.equalsIgnoreCase("info2")) {
{
v.sendMessage(ChatColor.GOLD + "This brush takes the following parameters:"); v.sendMessage(ChatColor.GOLD + "This brush takes the following parameters:");
v.sendMessage(ChatColor.AQUA + "minr# - minimum roots (whole number)"); v.sendMessage(ChatColor.AQUA + "minr# - minimum roots (whole number)");
v.sendMessage(ChatColor.AQUA + "maxr# - maximum roots (whole number)"); v.sendMessage(ChatColor.AQUA + "maxr# - maximum roots (whole number)");
@ -636,114 +543,73 @@ public class GenerateTreeBrush extends Brush
v.sendMessage(ChatColor.AQUA + "default - restore default params"); v.sendMessage(ChatColor.AQUA + "default - restore default params");
return; return;
} }
if (parameter.startsWith("lt")) if (parameter.startsWith("lt")) { // Leaf Type
{ // Leaf Type
this.leafType = BukkitAdapter.adapt(BlockTypes.parse(parameter.replace("lt", ""))); this.leafType = BukkitAdapter.adapt(BlockTypes.parse(parameter.replace("lt", "")));
v.sendMessage(ChatColor.BLUE + "Leaf Type set to " + this.leafType); v.sendMessage(ChatColor.BLUE + "Leaf Type set to " + this.leafType);
} } else if (parameter.startsWith("wt")) { // Wood Type
else if (parameter.startsWith("wt"))
{ // Wood Type
this.woodType = BukkitAdapter.adapt(BlockTypes.parse(parameter.replace("wt", ""))); this.woodType = BukkitAdapter.adapt(BlockTypes.parse(parameter.replace("wt", "")));
v.sendMessage(ChatColor.BLUE + "Wood Type set to " + this.woodType); v.sendMessage(ChatColor.BLUE + "Wood Type set to " + this.woodType);
} } else if (parameter.startsWith("tt")) { // Tree Thickness
else if (parameter.startsWith("tt"))
{ // Tree Thickness
this.thickness = Integer.parseInt(parameter.replace("tt", "")); this.thickness = Integer.parseInt(parameter.replace("tt", ""));
v.sendMessage(ChatColor.BLUE + "Thickness set to " + this.thickness); v.sendMessage(ChatColor.BLUE + "Thickness set to " + this.thickness);
} } else if (parameter.startsWith("rf")) { // Root Float
else if (parameter.startsWith("rf"))
{ // Root Float
this.rootFloat = Boolean.parseBoolean(parameter.replace("rf", "")); this.rootFloat = Boolean.parseBoolean(parameter.replace("rf", ""));
v.sendMessage(ChatColor.BLUE + "Floating Roots set to " + this.rootFloat); v.sendMessage(ChatColor.BLUE + "Floating Roots set to " + this.rootFloat);
} } else if (parameter.startsWith("sh")) { // Starting Height
else if (parameter.startsWith("sh"))
{ // Starting Height
this.startHeight = Integer.parseInt(parameter.replace("sh", "")); this.startHeight = Integer.parseInt(parameter.replace("sh", ""));
v.sendMessage(ChatColor.BLUE + "Starting Height set to " + this.startHeight); v.sendMessage(ChatColor.BLUE + "Starting Height set to " + this.startHeight);
} } else if (parameter.startsWith("rl")) { // Root Length
else if (parameter.startsWith("rl"))
{ // Root Length
this.rootLength = Integer.parseInt(parameter.replace("rl", "")); this.rootLength = Integer.parseInt(parameter.replace("rl", ""));
v.sendMessage(ChatColor.BLUE + "Root Length set to " + this.rootLength); v.sendMessage(ChatColor.BLUE + "Root Length set to " + this.rootLength);
} } else if (parameter.startsWith("minr")) { // Minimum Roots
else if (parameter.startsWith("minr"))
{ // Minimum Roots
this.minRoots = Integer.parseInt(parameter.replace("minr", "")); this.minRoots = Integer.parseInt(parameter.replace("minr", ""));
if (this.minRoots > this.maxRoots) if (this.minRoots > this.maxRoots) {
{
this.minRoots = this.maxRoots; this.minRoots = this.maxRoots;
v.sendMessage(ChatColor.RED + "Minimum Roots can't exceed Maximum Roots, has been set to " + this.minRoots + " Instead!"); v.sendMessage(ChatColor.RED + "Minimum Roots can't exceed Maximum Roots, has been set to " + this.minRoots + " Instead!");
} } else {
else
{
v.sendMessage(ChatColor.BLUE + "Minimum Roots set to " + this.minRoots); v.sendMessage(ChatColor.BLUE + "Minimum Roots set to " + this.minRoots);
} }
} } else if (parameter.startsWith("maxr")) { // Maximum Roots
else if (parameter.startsWith("maxr"))
{ // Maximum Roots
this.maxRoots = Integer.parseInt(parameter.replace("maxr", "")); this.maxRoots = Integer.parseInt(parameter.replace("maxr", ""));
if (this.minRoots > this.maxRoots) if (this.minRoots > this.maxRoots) {
{
this.maxRoots = this.minRoots; this.maxRoots = this.minRoots;
v.sendMessage(ChatColor.RED + "Maximum Roots can't be lower than Minimum Roots, has been set to " + this.minRoots + " Instead!"); v.sendMessage(ChatColor.RED + "Maximum Roots can't be lower than Minimum Roots, has been set to " + this.minRoots + " Instead!");
} } else {
else
{
v.sendMessage(ChatColor.BLUE + "Maximum Roots set to " + this.maxRoots); v.sendMessage(ChatColor.BLUE + "Maximum Roots set to " + this.maxRoots);
} }
} } else if (parameter.startsWith("ts")) { // Trunk Slope Chance
else if (parameter.startsWith("ts"))
{ // Trunk Slope Chance
this.slopeChance = Integer.parseInt(parameter.replace("ts", "")); this.slopeChance = Integer.parseInt(parameter.replace("ts", ""));
v.sendMessage(ChatColor.BLUE + "Trunk Slope set to " + this.slopeChance); v.sendMessage(ChatColor.BLUE + "Trunk Slope set to " + this.slopeChance);
} } else if (parameter.startsWith("minh")) { // Height Minimum
else if (parameter.startsWith("minh"))
{ // Height Minimum
this.heightMininmum = Integer.parseInt(parameter.replace("minh", "")); this.heightMininmum = Integer.parseInt(parameter.replace("minh", ""));
if (this.heightMininmum > this.heightMaximum) if (this.heightMininmum > this.heightMaximum) {
{
this.heightMininmum = this.heightMaximum; this.heightMininmum = this.heightMaximum;
v.sendMessage(ChatColor.RED + "Minimum Height exceed than Maximum Height, has been set to " + this.heightMininmum + " Instead!"); v.sendMessage(ChatColor.RED + "Minimum Height exceed than Maximum Height, has been set to " + this.heightMininmum + " Instead!");
} } else {
else
{
v.sendMessage(ChatColor.BLUE + "Minimum Height set to " + this.heightMininmum); v.sendMessage(ChatColor.BLUE + "Minimum Height set to " + this.heightMininmum);
} }
} } else if (parameter.startsWith("maxh")) { // Height Maximum
else if (parameter.startsWith("maxh"))
{ // Height Maximum
this.heightMaximum = Integer.parseInt(parameter.replace("maxh", "")); this.heightMaximum = Integer.parseInt(parameter.replace("maxh", ""));
if (this.heightMininmum > this.heightMaximum) if (this.heightMininmum > this.heightMaximum) {
{
this.heightMaximum = this.heightMininmum; this.heightMaximum = this.heightMininmum;
v.sendMessage(ChatColor.RED + "Maximum Height can't be lower than Minimum Height, has been set to " + this.heightMaximum + " Instead!"); v.sendMessage(ChatColor.RED + "Maximum Height can't be lower than Minimum Height, has been set to " + this.heightMaximum + " Instead!");
} } else {
else
{
v.sendMessage(ChatColor.BLUE + "Maximum Roots set to " + this.heightMaximum); v.sendMessage(ChatColor.BLUE + "Maximum Roots set to " + this.heightMaximum);
} }
} } else if (parameter.startsWith("bl")) { // Branch Length
else if (parameter.startsWith("bl"))
{ // Branch Length
this.branchLength = Integer.parseInt(parameter.replace("bl", "")); this.branchLength = Integer.parseInt(parameter.replace("bl", ""));
v.sendMessage(ChatColor.BLUE + "Branch Length set to " + this.branchLength); v.sendMessage(ChatColor.BLUE + "Branch Length set to " + this.branchLength);
} } else if (parameter.startsWith("maxl")) { // Leaf Node Max Size
else if (parameter.startsWith("maxl"))
{ // Leaf Node Max Size
this.nodeMax = Integer.parseInt(parameter.replace("maxl", "")); this.nodeMax = Integer.parseInt(parameter.replace("maxl", ""));
v.sendMessage(ChatColor.BLUE + "Leaf Max Thickness set to " + this.nodeMax + " (Default 4)"); v.sendMessage(ChatColor.BLUE + "Leaf Max Thickness set to " + this.nodeMax + " (Default 4)");
} } else if (parameter.startsWith("minl")) { // Leaf Node Min Size
else if (parameter.startsWith("minl"))
{ // Leaf Node Min Size
this.nodeMin = Integer.parseInt(parameter.replace("minl", "")); this.nodeMin = Integer.parseInt(parameter.replace("minl", ""));
v.sendMessage(ChatColor.BLUE + "Leaf Min Thickness set to " + this.nodeMin + " (Default 3)"); v.sendMessage(ChatColor.BLUE + "Leaf Min Thickness set to " + this.nodeMin + " (Default 3)");
// ------- // -------
// Presets // Presets
// ------- // -------
} } else if (parameter.startsWith("default")) { // Default settings.
else if (parameter.startsWith("default"))
{ // Default settings.
this.leafType = Material.OAK_LEAVES; this.leafType = Material.OAK_LEAVES;
this.woodType = Material.OAK_WOOD; this.woodType = Material.OAK_WOOD;
this.rootFloat = false; this.rootFloat = false;
@ -759,14 +625,10 @@ public class GenerateTreeBrush extends Brush
this.nodeMax = 4; this.nodeMax = 4;
this.nodeMin = 3; this.nodeMin = 3;
v.sendMessage(ChatColor.GOLD + "Brush reset to default parameters."); v.sendMessage(ChatColor.GOLD + "Brush reset to default parameters.");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! \"" + par[i] + "\" is not a valid statement. Please use the 'info' parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! \"" + par[i] + "\" is not a valid statement. Please use the 'info' parameter to display parameter info.");
} }
@ -774,8 +636,7 @@ public class GenerateTreeBrush extends Brush
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.generatetree"; return "voxelsniper.brush.generatetree";
} }
} }

Datei anzeigen

@ -1,14 +1,8 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import java.util.ArrayList;
import java.util.Random;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -16,13 +10,15 @@ import org.bukkit.block.Block;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.bukkit.util.noise.PerlinNoiseGenerator; import org.bukkit.util.noise.PerlinNoiseGenerator;
import java.util.ArrayList;
import java.util.Random;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#The_Heat_Ray * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Heat_Ray
* *
* @author Gavjenks * @author Gavjenks
*/ */
public class HeatRayBrush extends Brush public class HeatRayBrush extends Brush {
{
/** /**
* @author MikeMatrix * @author MikeMatrix
@ -46,13 +42,7 @@ public class HeatRayBrush extends Brush
private static final ArrayList<Material> FLAMABLE_BLOCKS = new ArrayList<>(); private static final ArrayList<Material> FLAMABLE_BLOCKS = new ArrayList<>();
private int octaves = 5; static {
private double frequency = 1;
private double amplitude = 0.3;
static
{
for (Material m : Material.values()) { for (Material m : Material.values()) {
if (!m.isLegacy() && m.isBlock() && m.isFlammable()) { if (!m.isLegacy() && m.isBlock() && m.isFlammable()) {
FLAMABLE_BLOCKS.add(m); FLAMABLE_BLOCKS.add(m);
@ -60,12 +50,15 @@ public class HeatRayBrush extends Brush
} }
} }
private int octaves = 5;
private double frequency = 1;
private double amplitude = 0.3;
/** /**
* Default Constructor. * Default Constructor.
*/ */
public HeatRayBrush() public HeatRayBrush() {
{
this.setName("Heat Ray"); this.setName("Heat Ray");
} }
@ -74,8 +67,7 @@ public class HeatRayBrush extends Brush
* *
* @param v * @param v
*/ */
public final void heatRay(final SnipeData v) public final void heatRay(final SnipeData v) {
{
final PerlinNoiseGenerator generator = new PerlinNoiseGenerator(new Random()); final PerlinNoiseGenerator generator = new PerlinNoiseGenerator(new Random());
final Vector targetLocation = this.getTargetBlock().getLocation().toVector(); final Vector targetLocation = this.getTargetBlock().getLocation().toVector();
@ -83,74 +75,55 @@ public class HeatRayBrush extends Brush
final Undo undo = new Undo(); final Undo undo = new Undo();
Block currentBlock; Block currentBlock;
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
{ for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) {
{
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--)
{
currentLocation.setX(this.getTargetBlock().getX() + x); currentLocation.setX(this.getTargetBlock().getX() + x);
currentLocation.setY(this.getTargetBlock().getY() + y); currentLocation.setY(this.getTargetBlock().getY() + y);
currentLocation.setZ(this.getTargetBlock().getZ() + z); currentLocation.setZ(this.getTargetBlock().getZ() + z);
if (currentLocation.toVector().isInSphere(targetLocation, v.getBrushSize())) if (currentLocation.toVector().isInSphere(targetLocation, v.getBrushSize())) {
{
currentBlock = currentLocation.getBlock(); currentBlock = currentLocation.getBlock();
if (currentBlock == null || currentBlock.getType() == Material.CHEST) if (currentBlock == null || currentBlock.getType() == Material.CHEST) {
{
continue; continue;
} }
if (currentBlock.isLiquid()) if (currentBlock.isLiquid()) {
{
undo.put(currentBlock); undo.put(currentBlock);
currentBlock.setType(Material.AIR); currentBlock.setType(Material.AIR);
continue; continue;
} }
if (HeatRayBrush.FLAMABLE_BLOCKS.contains(currentBlock.getType())) if (HeatRayBrush.FLAMABLE_BLOCKS.contains(currentBlock.getType())) {
{
undo.put(currentBlock); undo.put(currentBlock);
currentBlock.setType(Material.FIRE); currentBlock.setType(Material.FIRE);
continue; continue;
} }
if (!currentBlock.getType().equals(Material.AIR)) if (!currentBlock.getType().equals(Material.AIR)) {
{
final double airDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude); final double airDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude);
final double fireDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude); final double fireDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude);
final double cobbleDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude); final double cobbleDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude);
final double obsidianDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude); final double obsidianDensity = generator.noise(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ(), this.octaves, this.frequency, this.amplitude);
if (obsidianDensity >= HeatRayBrush.REQUIRED_OBSIDIAN_DENSITY) if (obsidianDensity >= HeatRayBrush.REQUIRED_OBSIDIAN_DENSITY) {
{
undo.put(currentBlock); undo.put(currentBlock);
if (currentBlock.getType() != Material.OBSIDIAN) if (currentBlock.getType() != Material.OBSIDIAN) {
{
currentBlock.setType(Material.OBSIDIAN); currentBlock.setType(Material.OBSIDIAN);
} }
} } else if (cobbleDensity >= HeatRayBrush.REQUIRED_COBBLE_DENSITY) {
else if (cobbleDensity >= HeatRayBrush.REQUIRED_COBBLE_DENSITY)
{
undo.put(currentBlock); undo.put(currentBlock);
if (currentBlock.getType() != Material.COBBLESTONE) if (currentBlock.getType() != Material.COBBLESTONE) {
{
currentBlock.setType(Material.COBBLESTONE); currentBlock.setType(Material.COBBLESTONE);
} }
} } else if (fireDensity >= HeatRayBrush.REQUIRED_FIRE_DENSITY) {
else if (fireDensity >= HeatRayBrush.REQUIRED_FIRE_DENSITY)
{
undo.put(currentBlock); undo.put(currentBlock);
if (currentBlock.getType() != Material.FIRE) if (currentBlock.getType() != Material.FIRE) {
{
currentBlock.setType(Material.FIRE); currentBlock.setType(Material.FIRE);
} }
} } else if (airDensity >= HeatRayBrush.REQUIRED_AIR_DENSITY) {
else if (airDensity >= HeatRayBrush.REQUIRED_AIR_DENSITY)
{
undo.put(currentBlock); undo.put(currentBlock);
if (!currentBlock.isEmpty()) if (!currentBlock.isEmpty()) {
{
currentBlock.setType(Material.AIR); currentBlock.setType(Material.AIR);
} }
} }
@ -165,20 +138,17 @@ public class HeatRayBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.heatRay(v); this.heatRay(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.heatRay(v); this.heatRay(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.GREEN + "Octaves: " + this.octaves); vm.custom(ChatColor.GREEN + "Octaves: " + this.octaves);
vm.custom(ChatColor.GREEN + "Amplitude: " + this.amplitude); vm.custom(ChatColor.GREEN + "Amplitude: " + this.amplitude);
@ -187,31 +157,23 @@ public class HeatRayBrush extends Brush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i].toLowerCase(); final String parameter = par[i].toLowerCase();
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Heat Ray brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Heat Ray brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b hr oct[int] -- Octaves parameter for the noise generator."); v.sendMessage(ChatColor.AQUA + "/b hr oct[int] -- Octaves parameter for the noise generator.");
v.sendMessage(ChatColor.AQUA + "/b hr amp[float] -- Amplitude parameter for the noise generator."); v.sendMessage(ChatColor.AQUA + "/b hr amp[float] -- Amplitude parameter for the noise generator.");
v.sendMessage(ChatColor.AQUA + "/b hr freq[float] -- Frequency parameter for the noise generator."); v.sendMessage(ChatColor.AQUA + "/b hr freq[float] -- Frequency parameter for the noise generator.");
} }
if (parameter.startsWith("oct")) if (parameter.startsWith("oct")) {
{
this.octaves = Integer.valueOf(parameter.replace("oct", "")); this.octaves = Integer.valueOf(parameter.replace("oct", ""));
v.getVoxelMessage().custom(ChatColor.GREEN + "Octaves: " + this.octaves); v.getVoxelMessage().custom(ChatColor.GREEN + "Octaves: " + this.octaves);
} } else if (parameter.startsWith("amp")) {
else if (parameter.startsWith("amp"))
{
this.amplitude = Double.valueOf(parameter.replace("amp", "")); this.amplitude = Double.valueOf(parameter.replace("amp", ""));
v.getVoxelMessage().custom(ChatColor.GREEN + "Amplitude: " + this.amplitude); v.getVoxelMessage().custom(ChatColor.GREEN + "Amplitude: " + this.amplitude);
} } else if (parameter.startsWith("freq")) {
else if (parameter.startsWith("freq"))
{
this.frequency = Double.valueOf(parameter.replace("freq", "")); this.frequency = Double.valueOf(parameter.replace("freq", ""));
v.getVoxelMessage().custom(ChatColor.GREEN + "Frequency: " + this.frequency); v.getVoxelMessage().custom(ChatColor.GREEN + "Frequency: " + this.frequency);
} }
@ -219,8 +181,7 @@ public class HeatRayBrush extends Brush
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.heatray"; return "voxelsniper.brush.heatray";
} }
} }

Datei anzeigen

@ -4,17 +4,11 @@ import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeAction; import com.thevoxelbox.voxelsniper.SnipeAction;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.block.Action;
/** /**
* Brush Interface. * Brush Interface.
*
*/ */
public interface IBrush public interface IBrush {
{
/** /**
* @param vm Message object * @param vm Message object

Datei anzeigen

@ -1,34 +1,30 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import java.util.Random;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.util.BlockIterator; import org.bukkit.util.BlockIterator;
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.Random;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Jagged_Line_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#Jagged_Line_Brush
* *
* @author Giltwist * @author Giltwist
* @author Monofraps * @author Monofraps
*/ */
public class JaggedLineBrush extends PerformBrush public class JaggedLineBrush extends PerformBrush {
{
private static final Vector HALF_BLOCK_OFFSET = new Vector(0.5, 0.5, 0.5); private static final Vector HALF_BLOCK_OFFSET = new Vector(0.5, 0.5, 0.5);
private static int timesUsed = 0;
private static final int RECURSION_MIN = 1; private static final int RECURSION_MIN = 1;
private static final int RECURSION_DEFAULT = 3; private static final int RECURSION_DEFAULT = 3;
private static final int RECURSION_MAX = 10; private static final int RECURSION_MAX = 10;
private static final int SPREAD_DEFAULT = 3; private static final int SPREAD_DEFAULT = 3;
private static int timesUsed = 0;
private Random random = new Random(); private Random random = new Random();
private Vector originCoords = null; private Vector originCoords = null;
private Vector targetCoords = new Vector(); private Vector targetCoords = new Vector();
@ -38,30 +34,23 @@ public class JaggedLineBrush extends PerformBrush
/** /**
* *
*/ */
public JaggedLineBrush() public JaggedLineBrush() {
{
this.setName("Jagged Line"); this.setName("Jagged Line");
} }
private void jaggedP(final SnipeData v) private void jaggedP(final SnipeData v) {
{
final Vector originClone = this.originCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET); final Vector originClone = this.originCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET);
final Vector targetClone = this.targetCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET); final Vector targetClone = this.targetCoords.clone().add(JaggedLineBrush.HALF_BLOCK_OFFSET);
final Vector direction = targetClone.clone().subtract(originClone); final Vector direction = targetClone.clone().subtract(originClone);
final double length = this.targetCoords.distance(this.originCoords); final double length = this.targetCoords.distance(this.originCoords);
if (length == 0) if (length == 0) {
{
this.current.perform((AsyncBlock) this.targetCoords.toLocation(this.getWorld()).getBlock()); this.current.perform((AsyncBlock) this.targetCoords.toLocation(this.getWorld()).getBlock());
} } else {
else for (final BlockIterator iterator = new BlockIterator(this.getWorld(), originClone, direction, 0, NumberConversions.round(length)); iterator.hasNext(); ) {
{
for (final BlockIterator iterator = new BlockIterator(this.getWorld(), originClone, direction, 0, NumberConversions.round(length)); iterator.hasNext(); )
{
final Block block = iterator.next(); final Block block = iterator.next();
for (int i = 0; i < recursion; i++) for (int i = 0; i < recursion; i++) {
{
this.current.perform(this.clampY(Math.round(block.getX() + this.random.nextInt(spread * 2) - spread), Math.round(block.getY() + this.random.nextInt(spread * 2) - spread), Math.round(block.getZ() + this.random.nextInt(spread * 2) - spread))); this.current.perform(this.clampY(Math.round(block.getX() + this.random.nextInt(spread * 2) - spread), Math.round(block.getY() + this.random.nextInt(spread * 2) - spread), Math.round(block.getZ() + this.random.nextInt(spread * 2) - spread)));
} }
} }
@ -71,10 +60,8 @@ public class JaggedLineBrush extends PerformBrush
} }
@Override @Override
public final void arrow(final SnipeData v) public final void arrow(final SnipeData v) {
{ if (originCoords == null) {
if (originCoords == null)
{
originCoords = new Vector(); originCoords = new Vector();
} }
this.originCoords = this.getTargetBlock().getLocation().toVector(); this.originCoords = this.getTargetBlock().getLocation().toVector();
@ -82,14 +69,10 @@ public class JaggedLineBrush extends PerformBrush
} }
@Override @Override
public final void powder(final SnipeData v) public final void powder(final SnipeData v) {
{ if (originCoords == null) {
if (originCoords == null)
{
v.sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow"); v.sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow");
} } else {
else
{
this.targetCoords = this.getTargetBlock().getLocation().toVector(); this.targetCoords = this.getTargetBlock().getLocation().toVector();
this.jaggedP(v); this.jaggedP(v);
} }
@ -97,51 +80,38 @@ public class JaggedLineBrush extends PerformBrush
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.GRAY + String.format("Recursion set to: %d", this.recursion)); vm.custom(ChatColor.GRAY + String.format("Recursion set to: %d", this.recursion));
vm.custom(ChatColor.GRAY + String.format("Spread set to: %d", this.spread)); vm.custom(ChatColor.GRAY + String.format("Spread set to: %d", this.spread));
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (final String parameter : par) {
for (final String parameter : par) try {
{ if (parameter.equalsIgnoreCase("info")) {
try
{
if (parameter.equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Jagged Line Brush instructions: Right click first point with the arrow. Right click with powder to draw a jagged line to set the second point."); v.sendMessage(ChatColor.GOLD + "Jagged Line Brush instructions: Right click first point with the arrow. Right click with powder to draw a jagged line to set the second point.");
v.sendMessage(ChatColor.AQUA + "/b j r# - sets the number of recursions (default 3, must be 1-10)"); v.sendMessage(ChatColor.AQUA + "/b j r# - sets the number of recursions (default 3, must be 1-10)");
v.sendMessage(ChatColor.AQUA + "/b j s# - sets the spread (default 3, must be 1-10)"); v.sendMessage(ChatColor.AQUA + "/b j s# - sets the spread (default 3, must be 1-10)");
return; return;
} }
if (parameter.startsWith("r")) if (parameter.startsWith("r")) {
{
final int temp = Integer.parseInt(parameter.substring(1)); final int temp = Integer.parseInt(parameter.substring(1));
if (temp >= RECURSION_MIN && temp <= RECURSION_MAX) if (temp >= RECURSION_MIN && temp <= RECURSION_MAX) {
{
this.recursion = temp; this.recursion = temp;
v.sendMessage(ChatColor.GREEN + "Recursion set to: " + this.recursion); v.sendMessage(ChatColor.GREEN + "Recursion set to: " + this.recursion);
} } else {
else
{
v.sendMessage(ChatColor.RED + "ERROR: Recursion must be " + RECURSION_MIN + "-" + RECURSION_MAX); v.sendMessage(ChatColor.RED + "ERROR: Recursion must be " + RECURSION_MIN + "-" + RECURSION_MAX);
} }
return; return;
} } else if (parameter.startsWith("s")) {
else if (parameter.startsWith("s"))
{
final int temp = Integer.parseInt(parameter.substring(1)); final int temp = Integer.parseInt(parameter.substring(1));
this.spread = temp; this.spread = temp;
v.sendMessage(ChatColor.GREEN + "Spread set to: " + this.spread); v.sendMessage(ChatColor.GREEN + "Spread set to: " + this.spread);
} }
} } catch (Exception exception) {
catch (Exception exception)
{
v.sendMessage(ChatColor.RED + String.format("Exception while parsing parameter: %s", parameter)); v.sendMessage(ChatColor.RED + String.format("Exception while parsing parameter: %s", parameter));
exception.printStackTrace(); exception.printStackTrace();
} }
@ -150,8 +120,7 @@ public class JaggedLineBrush extends PerformBrush
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.jaggedline"; return "voxelsniper.brush.jaggedline";
} }
} }

Datei anzeigen

@ -18,8 +18,7 @@ import java.util.List;
* @author Voxel * @author Voxel
* @author Monofraps * @author Monofraps
*/ */
public class JockeyBrush extends Brush public class JockeyBrush extends Brush {
{
private static final int ENTITY_STACK_LIMIT = 50; private static final int ENTITY_STACK_LIMIT = 50;
private JockeyType jockeyType = JockeyType.NORMAL_ALL_ENTITIES; private JockeyType jockeyType = JockeyType.NORMAL_ALL_ENTITIES;
private Entity jockeyedEntity = null; private Entity jockeyedEntity = null;
@ -27,13 +26,11 @@ public class JockeyBrush extends Brush
/** /**
* *
*/ */
public JockeyBrush() public JockeyBrush() {
{
this.setName("Jockey"); this.setName("Jockey");
} }
private void sitOn(final SnipeData v) private void sitOn(final SnipeData v) {
{
final Chunk targetChunk = this.getWorld().getChunkAt(this.getTargetBlock().getLocation()); final Chunk targetChunk = this.getWorld().getChunkAt(this.getTargetBlock().getLocation());
final int targetChunkX = targetChunk.getX(); final int targetChunkX = targetChunk.getX();
final int targetChunkZ = targetChunk.getZ(); final int targetChunkZ = targetChunk.getZ();
@ -41,21 +38,15 @@ public class JockeyBrush extends Brush
double range = Double.MAX_VALUE; double range = Double.MAX_VALUE;
Entity closest = null; Entity closest = null;
for (int x = targetChunkX - 1; x <= targetChunkX + 1; x++) for (int x = targetChunkX - 1; x <= targetChunkX + 1; x++) {
{ for (int y = targetChunkZ - 1; y <= targetChunkZ + 1; y++) {
for (int y = targetChunkZ - 1; y <= targetChunkZ + 1; y++) for (final Entity entity : this.getWorld().getChunkAt(x, y).getEntities()) {
{ if (entity.getEntityId() == v.owner().getPlayer().getEntityId()) {
for (final Entity entity : this.getWorld().getChunkAt(x, y).getEntities())
{
if (entity.getEntityId() == v.owner().getPlayer().getEntityId())
{
continue; continue;
} }
if (jockeyType == JockeyType.NORMAL_PLAYER_ONLY || jockeyType == JockeyType.INVERSE_PLAYER_ONLY) if (jockeyType == JockeyType.NORMAL_PLAYER_ONLY || jockeyType == JockeyType.INVERSE_PLAYER_ONLY) {
{ if (!(entity instanceof Player)) {
if (!(entity instanceof Player))
{
continue; continue;
} }
} }
@ -63,8 +54,7 @@ public class JockeyBrush extends Brush
final Location entityLocation = entity.getLocation(); final Location entityLocation = entity.getLocation();
final double entityDistance = entityLocation.distance(v.owner().getPlayer().getLocation()); final double entityDistance = entityLocation.distance(v.owner().getPlayer().getLocation());
if (entityDistance < range) if (entityDistance < range) {
{
range = entityDistance; range = entityDistance;
closest = entity; closest = entity;
} }
@ -72,67 +62,49 @@ public class JockeyBrush extends Brush
} }
} }
if (closest != null) if (closest != null) {
{
final Player player = v.owner().getPlayer(); final Player player = v.owner().getPlayer();
final PlayerTeleportEvent playerTeleportEvent = new PlayerTeleportEvent(player, player.getLocation(), closest.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); final PlayerTeleportEvent playerTeleportEvent = new PlayerTeleportEvent(player, player.getLocation(), closest.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
Bukkit.getPluginManager().callEvent(playerTeleportEvent); Bukkit.getPluginManager().callEvent(playerTeleportEvent);
if (!playerTeleportEvent.isCancelled()) if (!playerTeleportEvent.isCancelled()) {
{ if (jockeyType == JockeyType.INVERSE_PLAYER_ONLY || jockeyType == JockeyType.INVERSE_ALL_ENTITIES) {
if (jockeyType == JockeyType.INVERSE_PLAYER_ONLY || jockeyType == JockeyType.INVERSE_ALL_ENTITIES)
{
player.addPassenger(closest); player.addPassenger(closest);
} } else {
else
{
closest.addPassenger(player); closest.addPassenger(player);
jockeyedEntity = closest; jockeyedEntity = closest;
} }
v.sendMessage(ChatColor.GREEN + "You are now saddles on entity: " + closest.getEntityId()); v.sendMessage(ChatColor.GREEN + "You are now saddles on entity: " + closest.getEntityId());
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Could not find any entities"); v.sendMessage(ChatColor.RED + "Could not find any entities");
} }
} }
private void stack(final SnipeData v) private void stack(final SnipeData v) {
{
final int brushSizeDoubled = v.getBrushSize() * 2; final int brushSizeDoubled = v.getBrushSize() * 2;
List<Entity> nearbyEntities = v.owner().getPlayer().getNearbyEntities(brushSizeDoubled, brushSizeDoubled, brushSizeDoubled); List<Entity> nearbyEntities = v.owner().getPlayer().getNearbyEntities(brushSizeDoubled, brushSizeDoubled, brushSizeDoubled);
Entity lastEntity = v.owner().getPlayer(); Entity lastEntity = v.owner().getPlayer();
int stackHeight = 0; int stackHeight = 0;
for (Entity entity : nearbyEntities) for (Entity entity : nearbyEntities) {
{ if (!(stackHeight >= ENTITY_STACK_LIMIT)) {
if (!(stackHeight >= ENTITY_STACK_LIMIT)) if (jockeyType == JockeyType.STACK_ALL_ENTITIES) {
{
if (jockeyType == JockeyType.STACK_ALL_ENTITIES)
{
lastEntity.addPassenger(entity); lastEntity.addPassenger(entity);
lastEntity = entity; lastEntity = entity;
stackHeight++; stackHeight++;
} } else if (jockeyType == JockeyType.STACK_PLAYER_ONLY) {
else if (jockeyType == JockeyType.STACK_PLAYER_ONLY) if (entity instanceof Player) {
{
if (entity instanceof Player)
{
lastEntity.addPassenger(entity); lastEntity.addPassenger(entity);
lastEntity = entity; lastEntity = entity;
stackHeight++; stackHeight++;
} }
} } else {
else
{
v.owner().getPlayer().sendMessage("You broke stack! :O"); v.owner().getPlayer().sendMessage("You broke stack! :O");
} }
} } else {
else
{
return; return;
} }
} }
@ -140,30 +112,21 @@ public class JockeyBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ if (jockeyType == JockeyType.STACK_ALL_ENTITIES || jockeyType == JockeyType.STACK_PLAYER_ONLY) {
if (jockeyType == JockeyType.STACK_ALL_ENTITIES || jockeyType == JockeyType.STACK_PLAYER_ONLY)
{
stack(v); stack(v);
} } else {
else
{
this.sitOn(v); this.sitOn(v);
} }
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (jockeyType == JockeyType.INVERSE_PLAYER_ONLY || jockeyType == JockeyType.INVERSE_ALL_ENTITIES) {
if (jockeyType == JockeyType.INVERSE_PLAYER_ONLY || jockeyType == JockeyType.INVERSE_ALL_ENTITIES)
{
v.owner().getPlayer().eject(); v.owner().getPlayer().eject();
v.owner().getPlayer().sendMessage(ChatColor.GOLD + "The guy on top of you has been ejected!"); v.owner().getPlayer().sendMessage(ChatColor.GOLD + "The guy on top of you has been ejected!");
} } else {
else if (jockeyedEntity != null) {
{
if (jockeyedEntity != null)
{
jockeyedEntity.eject(); jockeyedEntity.eject();
jockeyedEntity = null; jockeyedEntity = null;
v.owner().getPlayer().sendMessage(ChatColor.GOLD + "You have been ejected!"); v.owner().getPlayer().sendMessage(ChatColor.GOLD + "You have been ejected!");
@ -173,106 +136,79 @@ public class JockeyBrush extends Brush
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom("Current jockey mode: " + ChatColor.GREEN + jockeyType.toString()); vm.custom("Current jockey mode: " + ChatColor.GREEN + jockeyType.toString());
vm.custom(ChatColor.GREEN + "Help: " + ChatColor.AQUA + "http://www.voxelwiki.com/minecraft/Voxelsniper#The_Jockey_Brush"); vm.custom(ChatColor.GREEN + "Help: " + ChatColor.AQUA + "http://www.voxelwiki.com/minecraft/Voxelsniper#The_Jockey_Brush");
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{
boolean inverse = false; boolean inverse = false;
boolean playerOnly = false; boolean playerOnly = false;
boolean stack = false; boolean stack = false;
try try {
{ for (String parameter : par) {
for (String parameter : par) if (parameter.startsWith("-i:")) {
{
if (parameter.startsWith("-i:"))
{
inverse = parameter.endsWith("y"); inverse = parameter.endsWith("y");
} }
if (parameter.startsWith("-po:")) if (parameter.startsWith("-po:")) {
{
playerOnly = parameter.endsWith("y"); playerOnly = parameter.endsWith("y");
} }
if (parameter.startsWith("-s:")) if (parameter.startsWith("-s:")) {
{
stack = parameter.endsWith("y"); stack = parameter.endsWith("y");
} }
} }
if (inverse) if (inverse) {
{ if (playerOnly) {
if (playerOnly)
{
jockeyType = JockeyType.INVERSE_PLAYER_ONLY; jockeyType = JockeyType.INVERSE_PLAYER_ONLY;
} } else {
else
{
jockeyType = JockeyType.INVERSE_ALL_ENTITIES; jockeyType = JockeyType.INVERSE_ALL_ENTITIES;
} }
} } else if (stack) {
else if (stack) if (playerOnly) {
{
if (playerOnly)
{
jockeyType = JockeyType.STACK_PLAYER_ONLY; jockeyType = JockeyType.STACK_PLAYER_ONLY;
} } else {
else
{
jockeyType = JockeyType.STACK_ALL_ENTITIES; jockeyType = JockeyType.STACK_ALL_ENTITIES;
} }
} } else {
else if (playerOnly) {
{
if (playerOnly)
{
jockeyType = JockeyType.NORMAL_PLAYER_ONLY; jockeyType = JockeyType.NORMAL_PLAYER_ONLY;
} } else {
else
{
jockeyType = JockeyType.NORMAL_ALL_ENTITIES; jockeyType = JockeyType.NORMAL_ALL_ENTITIES;
} }
} }
v.sendMessage("Current jockey mode: " + ChatColor.GREEN + jockeyType.toString()); v.sendMessage("Current jockey mode: " + ChatColor.GREEN + jockeyType.toString());
} } catch (Exception exception) {
catch (Exception exception)
{
v.sendMessage("Error while parsing your arguments."); v.sendMessage("Error while parsing your arguments.");
exception.printStackTrace(); exception.printStackTrace();
} }
} }
@Override
public String getPermissionNode() {
return "voxelsniper.brush.jockey";
}
/** /**
* Available types of jockey modes. * Available types of jockey modes.
*/ */
private enum JockeyType private enum JockeyType {
{
NORMAL_ALL_ENTITIES("Normal (All)"), NORMAL_PLAYER_ONLY("Normal (Player only)"), INVERSE_ALL_ENTITIES("Inverse (All)"), INVERSE_PLAYER_ONLY("Inverse (Player only)"), STACK_ALL_ENTITIES("Stack (All)"), STACK_PLAYER_ONLY("Stack (Player only)"); NORMAL_ALL_ENTITIES("Normal (All)"), NORMAL_PLAYER_ONLY("Normal (Player only)"), INVERSE_ALL_ENTITIES("Inverse (All)"), INVERSE_PLAYER_ONLY("Inverse (Player only)"), STACK_ALL_ENTITIES("Stack (All)"), STACK_PLAYER_ONLY("Stack (Player only)");
private String name; private String name;
JockeyType(String name) JockeyType(String name) {
{
this.name = name; this.name = name;
} }
@Override @Override
public String toString() public String toString() {
{
return this.name; return this.name;
} }
} }
@Override
public String getPermissionNode()
{
return "voxelsniper.brush.jockey";
}
} }

Datei anzeigen

@ -6,38 +6,32 @@ import com.thevoxelbox.voxelsniper.SnipeData;
/** /**
* @author Gavjenks * @author Gavjenks
*/ */
public class LightningBrush extends Brush public class LightningBrush extends Brush {
{
/** /**
* *
*/ */
public LightningBrush() public LightningBrush() {
{
this.setName("Lightning"); this.setName("Lightning");
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.brushMessage("Lightning Brush! Please use in moderation."); vm.brushMessage("Lightning Brush! Please use in moderation.");
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.getWorld().strikeLightning(this.getTargetBlock().getLocation()); this.getWorld().strikeLightning(this.getTargetBlock().getLocation());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.getWorld().strikeLightning(this.getTargetBlock().getLocation()); this.getWorld().strikeLightning(this.getTargetBlock().getLocation());
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.lightning"; return "voxelsniper.brush.lightning";
} }
} }

Datei anzeigen

@ -6,8 +6,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.util.BlockIterator; import org.bukkit.util.BlockIterator;
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -19,8 +17,7 @@ import org.bukkit.util.Vector;
* @author giltwist * @author giltwist
* @author MikeMatrix * @author MikeMatrix
*/ */
public class LineBrush extends PerformBrush public class LineBrush extends PerformBrush {
{
private static final Vector HALF_BLOCK_OFFSET = new Vector(0.5, 0.5, 0.5); private static final Vector HALF_BLOCK_OFFSET = new Vector(0.5, 0.5, 0.5);
private Vector originCoords = null; private Vector originCoords = null;
private Vector targetCoords = new Vector(); private Vector targetCoords = new Vector();
@ -29,42 +26,33 @@ public class LineBrush extends PerformBrush
/** /**
* *
*/ */
public LineBrush() public LineBrush() {
{
this.setName("Line"); this.setName("Line");
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Line Brush instructions: Right click first point with the arrow. Right click with powder to draw a line to set the second point."); v.sendMessage(ChatColor.GOLD + "Line Brush instructions: Right click first point with the arrow. Right click with powder to draw a line to set the second point.");
} }
} }
private void linePowder(final SnipeData v) private void linePowder(final SnipeData v) {
{
final Vector originClone = this.originCoords.clone().add(LineBrush.HALF_BLOCK_OFFSET); final Vector originClone = this.originCoords.clone().add(LineBrush.HALF_BLOCK_OFFSET);
final Vector targetClone = this.targetCoords.clone().add(LineBrush.HALF_BLOCK_OFFSET); final Vector targetClone = this.targetCoords.clone().add(LineBrush.HALF_BLOCK_OFFSET);
final Vector direction = targetClone.clone().subtract(originClone); final Vector direction = targetClone.clone().subtract(originClone);
final double length = this.targetCoords.distance(this.originCoords); final double length = this.targetCoords.distance(this.originCoords);
if (length == 0) if (length == 0) {
{
this.current.perform((AsyncBlock) this.targetCoords.toLocation(this.targetWorld).getBlock()); this.current.perform((AsyncBlock) this.targetCoords.toLocation(this.targetWorld).getBlock());
} } else {
else for (final BlockIterator blockIterator = new BlockIterator(this.targetWorld, originClone, direction, 0, NumberConversions.round(length)); blockIterator.hasNext(); ) {
{
for (final BlockIterator blockIterator = new BlockIterator(this.targetWorld, originClone, direction, 0, NumberConversions.round(length)); blockIterator.hasNext(); )
{
final AsyncBlock currentBlock = (AsyncBlock) blockIterator.next(); final AsyncBlock currentBlock = (AsyncBlock) blockIterator.next();
this.current.perform(currentBlock); this.current.perform(currentBlock);
} }
@ -74,30 +62,24 @@ public class LineBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.originCoords = this.getTargetBlock().getLocation().toVector(); this.originCoords = this.getTargetBlock().getLocation().toVector();
this.targetWorld = this.getTargetBlock().getWorld(); this.targetWorld = this.getTargetBlock().getWorld();
v.owner().getPlayer().sendMessage(ChatColor.DARK_PURPLE + "First point selected."); v.owner().getPlayer().sendMessage(ChatColor.DARK_PURPLE + "First point selected.");
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (this.originCoords == null || !this.getTargetBlock().getWorld().equals(this.targetWorld)) {
if (this.originCoords == null || !this.getTargetBlock().getWorld().equals(this.targetWorld))
{
v.owner().getPlayer().sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow"); v.owner().getPlayer().sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow");
} } else {
else
{
this.targetCoords = this.getTargetBlock().getLocation().toVector(); this.targetCoords = this.getTargetBlock().getLocation().toVector();
this.linePowder(v); this.linePowder(v);
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.line"; return "voxelsniper.brush.line";
} }
} }

Datei anzeigen

@ -9,14 +9,11 @@ import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
/** /**
* Moves a selection blockPositionY a certain amount. * Moves a selection blockPositionY a certain amount.
@ -24,8 +21,7 @@ import java.util.TreeSet;
* *
* @author MikeMatrix * @author MikeMatrix
*/ */
public class MoveBrush extends Brush public class MoveBrush extends Brush {
{
/** /**
* Saved direction. * Saved direction.
*/ */
@ -38,8 +34,7 @@ public class MoveBrush extends Brush
/** /**
* *
*/ */
public MoveBrush() public MoveBrush() {
{
this.setName("Move"); this.setName("Move");
} }
@ -51,10 +46,8 @@ public class MoveBrush extends Brush
* @param direction * @param direction
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void moveSelection(final SnipeData v, final Selection selection, final int[] direction) private void moveSelection(final SnipeData v, final Selection selection, final int[] direction) {
{ if (selection.getBlockStates().size() > 0) {
if (selection.getBlockStates().size() > 0)
{
final AsyncWorld world = selection.getBlockStates().get(0).getWorld(); final AsyncWorld world = selection.getBlockStates().get(0).getWorld();
final Undo undo = new Undo(); final Undo undo = new Undo();
@ -67,36 +60,28 @@ public class MoveBrush extends Brush
movedLocation2.add(direction[0], direction[1], direction[2]); movedLocation2.add(direction[0], direction[1], direction[2]);
newSelection.setLocation1(movedLocation1); newSelection.setLocation1(movedLocation1);
newSelection.setLocation2(movedLocation2); newSelection.setLocation2(movedLocation2);
try try {
{
newSelection.calculateRegion(); newSelection.calculateRegion();
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.getVoxelMessage().brushMessage("The new Selection has more blocks than the original selection. This should never happen!"); v.getVoxelMessage().brushMessage("The new Selection has more blocks than the original selection. This should never happen!");
} }
for (final BlockState blockState : selection.getBlockStates()) for (final BlockState blockState : selection.getBlockStates()) {
{
undoSet.add(blockState.getBlock()); undoSet.add(blockState.getBlock());
} }
for (final BlockState blockState : newSelection.getBlockStates()) for (final BlockState blockState : newSelection.getBlockStates()) {
{
undoSet.add(blockState.getBlock()); undoSet.add(blockState.getBlock());
} }
for (final Block block : undoSet) for (final Block block : undoSet) {
{
undo.put(block); undo.put(block);
} }
v.owner().storeUndo(undo); v.owner().storeUndo(undo);
for (final BlockState blockState : selection.getBlockStates()) for (final BlockState blockState : selection.getBlockStates()) {
{
blockState.getBlock().setType(Material.AIR); blockState.getBlock().setType(Material.AIR);
} }
for (final AsyncBlockState blockState : selection.getBlockStates()) for (final AsyncBlockState blockState : selection.getBlockStates()) {
{
final AsyncBlock affectedBlock = world.getBlockAt(blockState.getX() + direction[0], blockState.getY() + direction[1], blockState.getZ() + direction[2]); final AsyncBlock affectedBlock = world.getBlockAt(blockState.getX() + direction[0], blockState.getY() + direction[1], blockState.getZ() + direction[2]);
affectedBlock.setTypeId(blockState.getTypeId()); affectedBlock.setTypeId(blockState.getTypeId());
affectedBlock.setPropertyId(blockState.getPropertyId()); affectedBlock.setPropertyId(blockState.getPropertyId());
@ -105,67 +90,51 @@ public class MoveBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ if (this.selection == null) {
if (this.selection == null)
{
this.selection = new Selection(); this.selection = new Selection();
} }
this.selection.setLocation1(this.getTargetBlock().getLocation()); this.selection.setLocation1(this.getTargetBlock().getLocation());
v.getVoxelMessage().brushMessage("Point 1 set."); v.getVoxelMessage().brushMessage("Point 1 set.");
try try {
{ if (this.selection.calculateRegion()) {
if (this.selection.calculateRegion())
{
this.moveSelection(v, this.selection, this.moveDirections); this.moveSelection(v, this.selection, this.moveDirections);
this.selection = null; this.selection = null;
} }
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(exception.getMessage()); v.sendMessage(exception.getMessage());
} }
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (this.selection == null) {
if (this.selection == null)
{
this.selection = new Selection(); this.selection = new Selection();
} }
this.selection.setLocation2(this.getTargetBlock().getLocation()); this.selection.setLocation2(this.getTargetBlock().getLocation());
v.getVoxelMessage().brushMessage("Point 2 set."); v.getVoxelMessage().brushMessage("Point 2 set.");
try try {
{ if (this.selection.calculateRegion()) {
if (this.selection.calculateRegion())
{
this.moveSelection(v, this.selection, this.moveDirections); this.moveSelection(v, this.selection, this.moveDirections);
this.selection = null; this.selection = null;
} }
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(exception.getMessage()); v.sendMessage(exception.getMessage());
} }
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.BLUE + "Move selection blockPositionY " + ChatColor.GOLD + "x:" + this.moveDirections[0] + " y:" + this.moveDirections[1] + " z:" + this.moveDirections[2]); vm.custom(ChatColor.BLUE + "Move selection blockPositionY " + ChatColor.GOLD + "x:" + this.moveDirections[0] + " y:" + this.moveDirections[1] + " z:" + this.moveDirections[2]);
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++) if (par[i].equalsIgnoreCase("info")) {
{
if (par[i].equalsIgnoreCase("info"))
{
v.getVoxelMessage().custom(ChatColor.GOLD + this.getName() + " Parameters:"); v.getVoxelMessage().custom(ChatColor.GOLD + this.getName() + " Parameters:");
v.getVoxelMessage().custom(ChatColor.AQUA + "/b mv x[int] -- set the x direction (positive => east)"); v.getVoxelMessage().custom(ChatColor.AQUA + "/b mv x[int] -- set the x direction (positive => east)");
v.getVoxelMessage().custom(ChatColor.AQUA + "/b mv y[int] -- set the y direction (positive => up)"); v.getVoxelMessage().custom(ChatColor.AQUA + "/b mv y[int] -- set the y direction (positive => up)");
@ -173,8 +142,7 @@ public class MoveBrush extends Brush
v.getVoxelMessage().custom(ChatColor.AQUA + "/b mv reset -- reset the brush (x:0 y:0 z:0)"); v.getVoxelMessage().custom(ChatColor.AQUA + "/b mv reset -- reset the brush (x:0 y:0 z:0)");
v.getVoxelMessage().custom(ChatColor.AQUA + "Use arrow and gunpowder to define two points."); v.getVoxelMessage().custom(ChatColor.AQUA + "Use arrow and gunpowder to define two points.");
} }
if (par[i].equalsIgnoreCase("reset")) if (par[i].equalsIgnoreCase("reset")) {
{
this.moveDirections[0] = 0; this.moveDirections[0] = 0;
this.moveDirections[1] = 0; this.moveDirections[1] = 0;
this.moveDirections[2] = 0; this.moveDirections[2] = 0;
@ -182,31 +150,30 @@ public class MoveBrush extends Brush
v.getVoxelMessage().custom(ChatColor.AQUA + "Y direction set to: " + this.moveDirections[1]); v.getVoxelMessage().custom(ChatColor.AQUA + "Y direction set to: " + this.moveDirections[1]);
v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]); v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]);
} }
if (par[i].toLowerCase().startsWith("x")) if (par[i].toLowerCase().startsWith("x")) {
{
this.moveDirections[0] = Integer.valueOf(par[i].substring(1)); this.moveDirections[0] = Integer.valueOf(par[i].substring(1));
v.getVoxelMessage().custom(ChatColor.AQUA + "X direction set to: " + this.moveDirections[0]); v.getVoxelMessage().custom(ChatColor.AQUA + "X direction set to: " + this.moveDirections[0]);
} } else if (par[i].toLowerCase().startsWith("y")) {
else if (par[i].toLowerCase().startsWith("y"))
{
this.moveDirections[1] = Integer.valueOf(par[i].substring(1)); this.moveDirections[1] = Integer.valueOf(par[i].substring(1));
v.getVoxelMessage().custom(ChatColor.AQUA + "Y direction set to: " + this.moveDirections[1]); v.getVoxelMessage().custom(ChatColor.AQUA + "Y direction set to: " + this.moveDirections[1]);
} } else if (par[i].toLowerCase().startsWith("z")) {
else if (par[i].toLowerCase().startsWith("z"))
{
this.moveDirections[2] = Integer.valueOf(par[i].substring(1)); this.moveDirections[2] = Integer.valueOf(par[i].substring(1));
v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]); v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]);
} }
} }
} }
@Override
public String getPermissionNode() {
return "voxelsniper.brush.move";
}
/** /**
* Selection Helper class. * Selection Helper class.
* *
* @author MikeMatrix * @author MikeMatrix
*/ */
private class Selection private class Selection {
{
/** /**
* Maximum amount of Blocks allowed blockPositionY the Selection. * Maximum amount of Blocks allowed blockPositionY the Selection.
*/ */
@ -230,29 +197,22 @@ public class MoveBrush extends Brush
* @return boolean success. * @return boolean success.
* @throws Exception Message to be sent to the player. * @throws Exception Message to be sent to the player.
*/ */
public boolean calculateRegion() throws Exception public boolean calculateRegion() throws Exception {
{ if (this.location1 != null && this.location2 != null) {
if (this.location1 != null && this.location2 != null) if (this.location1.getWorld().equals(this.location2.getWorld())) {
{
if (this.location1.getWorld().equals(this.location2.getWorld()))
{
final int lowX = ((this.location1.getBlockX() <= this.location2.getBlockX()) ? this.location1.getBlockX() : this.location2.getBlockX()); final int lowX = ((this.location1.getBlockX() <= this.location2.getBlockX()) ? this.location1.getBlockX() : this.location2.getBlockX());
final int lowY = (this.location1.getBlockY() <= this.location2.getBlockY()) ? this.location1.getBlockY() : this.location2.getBlockY(); final int lowY = (this.location1.getBlockY() <= this.location2.getBlockY()) ? this.location1.getBlockY() : this.location2.getBlockY();
final int lowZ = (this.location1.getBlockZ() <= this.location2.getBlockZ()) ? this.location1.getBlockZ() : this.location2.getBlockZ(); final int lowZ = (this.location1.getBlockZ() <= this.location2.getBlockZ()) ? this.location1.getBlockZ() : this.location2.getBlockZ();
final int highX = (this.location1.getBlockX() >= this.location2.getBlockX()) ? this.location1.getBlockX() : this.location2.getBlockX(); final int highX = (this.location1.getBlockX() >= this.location2.getBlockX()) ? this.location1.getBlockX() : this.location2.getBlockX();
final int highY = (this.location1.getBlockY() >= this.location2.getBlockY()) ? this.location1.getBlockY() : this.location2.getBlockY(); final int highY = (this.location1.getBlockY() >= this.location2.getBlockY()) ? this.location1.getBlockY() : this.location2.getBlockY();
final int highZ = (this.location1.getBlockZ() >= this.location2.getBlockZ()) ? this.location1.getBlockZ() : this.location2.getBlockZ(); final int highZ = (this.location1.getBlockZ() >= this.location2.getBlockZ()) ? this.location1.getBlockZ() : this.location2.getBlockZ();
if (Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY) > Selection.MAX_BLOCK_COUNT) if (Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY) > Selection.MAX_BLOCK_COUNT) {
{
throw new Exception(ChatColor.RED + "Selection size above hardcoded limit, please use a smaller selection."); throw new Exception(ChatColor.RED + "Selection size above hardcoded limit, please use a smaller selection.");
} }
final AsyncWorld world = (AsyncWorld) this.location1.getWorld(); final AsyncWorld world = (AsyncWorld) this.location1.getWorld();
for (int y = lowY; y <= highY; y++) for (int y = lowY; y <= highY; y++) {
{ for (int x = lowX; x <= highX; x++) {
for (int x = lowX; x <= highX; x++) for (int z = lowZ; z <= highZ; z++) {
{
for (int z = lowZ; z <= highZ; z++)
{
this.blockStates.add(world.getBlockAt(x, y, z).getState()); this.blockStates.add(world.getBlockAt(x, y, z).getState());
} }
} }
@ -266,47 +226,36 @@ public class MoveBrush extends Brush
/** /**
* @return ArrayList<BlockState> calculated BlockStates of defined region. * @return ArrayList<BlockState> calculated BlockStates of defined region.
*/ */
public ArrayList<AsyncBlockState> getBlockStates() public ArrayList<AsyncBlockState> getBlockStates() {
{
return this.blockStates; return this.blockStates;
} }
/** /**
* @return Location * @return Location
*/ */
public Location getLocation1() public Location getLocation1() {
{
return this.location1; return this.location1;
} }
/** /**
* @param location1 * @param location1
*/ */
public void setLocation1(final Location location1) public void setLocation1(final Location location1) {
{
this.location1 = location1; this.location1 = location1;
} }
/** /**
* @return Location * @return Location
*/ */
public Location getLocation2() public Location getLocation2() {
{
return this.location2; return this.location2;
} }
/** /**
* @param location2 * @param location2
*/ */
public void setLocation2(final Location location2) public void setLocation2(final Location location2) {
{
this.location2 = location2; this.location2 = location2;
} }
} }
@Override
public String getPermissionNode()
{
return "voxelsniper.brush.move";
}
} }

Datei anzeigen

@ -14,8 +14,7 @@ import org.bukkit.block.Block;
* *
* @author Voxel * @author Voxel
*/ */
public class OceanBrush extends Brush public class OceanBrush extends Brush {
{
private static final int WATER_LEVEL_DEFAULT = 62; // y=63 -- we are using array indices here private static final int WATER_LEVEL_DEFAULT = 62; // y=63 -- we are using array indices here
private static final int WATER_LEVEL_MIN = 12; private static final int WATER_LEVEL_MIN = 12;
private static final int LOW_CUT_LEVEL = 12; private static final int LOW_CUT_LEVEL = 12;
@ -26,18 +25,14 @@ public class OceanBrush extends Brush
/** /**
* *
*/ */
public OceanBrush() public OceanBrush() {
{
this.setName("OCEANATOR 5000(tm)"); this.setName("OCEANATOR 5000(tm)");
} }
private int getHeight(final int bx, final int bz) private int getHeight(final int bx, final int bz) {
{ for (int y = this.getWorld().getHighestBlockYAt(bx, bz); y > 0; y--) {
for (int y = this.getWorld().getHighestBlockYAt(bx, bz); y > 0; y--)
{
final Material material = this.clampY(bx, y, bz).getType(); final Material material = this.clampY(bx, y, bz).getType();
if (material.isSolid()) if (material.isSolid()) {
{
return y; return y;
} }
} }
@ -48,8 +43,7 @@ public class OceanBrush extends Brush
* @param v * @param v
* @param undo * @param undo
*/ */
protected final void oceanator(final SnipeData v, final Undo undo) protected final void oceanator(final SnipeData v, final Undo undo) {
{
final AsyncWorld world = this.getWorld(); final AsyncWorld world = this.getWorld();
final int minX = (int) Math.floor((this.getTargetBlock().getX() - v.getBrushSize())); final int minX = (int) Math.floor((this.getTargetBlock().getX() - v.getBrushSize()));
@ -57,10 +51,8 @@ public class OceanBrush extends Brush
final int maxX = (int) Math.floor((this.getTargetBlock().getX() + v.getBrushSize())); final int maxX = (int) Math.floor((this.getTargetBlock().getX() + v.getBrushSize()));
final int maxZ = (int) Math.floor((this.getTargetBlock().getZ() + v.getBrushSize())); final int maxZ = (int) Math.floor((this.getTargetBlock().getZ() + v.getBrushSize()));
for (int x = minX; x <= maxX; x++) for (int x = minX; x <= maxX; x++) {
{ for (int z = minZ; z <= maxZ; z++) {
for (int z = minZ; z <= maxZ; z++)
{
final int currentHeight = getHeight(x, z); final int currentHeight = getHeight(x, z);
final int wLevelDiff = currentHeight - (this.waterLevel - 1); final int wLevelDiff = currentHeight - (this.waterLevel - 1);
final int newSeaFloorLevel = ((this.waterLevel - wLevelDiff) >= LOW_CUT_LEVEL) ? this.waterLevel - wLevelDiff : LOW_CUT_LEVEL; final int newSeaFloorLevel = ((this.waterLevel - wLevelDiff) >= LOW_CUT_LEVEL) ? this.waterLevel - wLevelDiff : LOW_CUT_LEVEL;
@ -68,25 +60,20 @@ public class OceanBrush extends Brush
final int highestY = this.getWorld().getHighestBlockYAt(x, z); final int highestY = this.getWorld().getHighestBlockYAt(x, z);
// go down from highest Y block down to new sea floor // go down from highest Y block down to new sea floor
for (int y = highestY; y > newSeaFloorLevel; y--) for (int y = highestY; y > newSeaFloorLevel; y--) {
{
final Block block = world.getBlockAt(x, y, z); final Block block = world.getBlockAt(x, y, z);
if (!block.getType().equals(Material.AIR)) if (!block.getType().equals(Material.AIR)) {
{
undo.put(block); undo.put(block);
block.setType(Material.AIR); block.setType(Material.AIR);
} }
} }
// go down from water level to new sea level // go down from water level to new sea level
for (int y = this.waterLevel; y > newSeaFloorLevel; y--) for (int y = this.waterLevel; y > newSeaFloorLevel; y--) {
{
final Block block = world.getBlockAt(x, y, z); final Block block = world.getBlockAt(x, y, z);
if (!block.getType().equals(Material.WATER)) if (!block.getType().equals(Material.WATER)) {
{
// do not put blocks into the undo we already put into // do not put blocks into the undo we already put into
if (!block.getType().equals(Material.AIR)) if (!block.getType().equals(Material.AIR)) {
{
undo.put(block); undo.put(block);
} }
block.setType(Material.WATER); block.setType(Material.WATER);
@ -94,11 +81,9 @@ public class OceanBrush extends Brush
} }
// cover the sea floor of required // cover the sea floor of required
if (this.coverFloor && (newSeaFloorLevel < this.waterLevel)) if (this.coverFloor && (newSeaFloorLevel < this.waterLevel)) {
{
AsyncBlock block = world.getBlockAt(x, newSeaFloorLevel, z); AsyncBlock block = world.getBlockAt(x, newSeaFloorLevel, z);
if (block.getTypeId() != v.getVoxelId()) if (block.getTypeId() != v.getVoxelId()) {
{
undo.put(block); undo.put(block);
block.setTypeId(v.getVoxelId()); block.setTypeId(v.getVoxelId());
} }
@ -108,57 +93,44 @@ public class OceanBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
Undo undo = new Undo(); Undo undo = new Undo();
this.oceanator(v, undo); this.oceanator(v, undo);
v.owner().storeUndo(undo); v.owner().storeUndo(undo);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
arrow(v); arrow(v);
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 0; i < par.length; i++) {
for (int i = 0; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
try try {
{ if (parameter.equalsIgnoreCase("info")) {
if (parameter.equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.BLUE + "Parameters:"); v.sendMessage(ChatColor.BLUE + "Parameters:");
v.sendMessage(ChatColor.GREEN + "-wlevel # " + ChatColor.BLUE + "-- Sets the water level (e.g. -wlevel 64)"); v.sendMessage(ChatColor.GREEN + "-wlevel # " + ChatColor.BLUE + "-- Sets the water level (e.g. -wlevel 64)");
v.sendMessage(ChatColor.GREEN + "-cfloor [y|n] " + ChatColor.BLUE + "-- Enables or disables sea floor cover (e.g. -cfloor y) (Cover material will be your voxel material)"); v.sendMessage(ChatColor.GREEN + "-cfloor [y|n] " + ChatColor.BLUE + "-- Enables or disables sea floor cover (e.g. -cfloor y) (Cover material will be your voxel material)");
} } else if (parameter.equalsIgnoreCase("-wlevel")) {
else if (parameter.equalsIgnoreCase("-wlevel")) if ((i + 1) >= par.length) {
{
if ((i + 1) >= par.length)
{
v.sendMessage(ChatColor.RED + "Missing parameter. Correct syntax: -wlevel [#] (e.g. -wlevel 64)"); v.sendMessage(ChatColor.RED + "Missing parameter. Correct syntax: -wlevel [#] (e.g. -wlevel 64)");
continue; continue;
} }
int temp = Integer.parseInt(par[++i]); int temp = Integer.parseInt(par[++i]);
if (temp <= WATER_LEVEL_MIN) if (temp <= WATER_LEVEL_MIN) {
{
v.sendMessage(ChatColor.RED + "Error: Your specified water level was below 12."); v.sendMessage(ChatColor.RED + "Error: Your specified water level was below 12.");
continue; continue;
} }
this.waterLevel = temp - 1; this.waterLevel = temp - 1;
v.sendMessage(ChatColor.BLUE + "Water level set to " + ChatColor.GREEN + (waterLevel + 1)); // +1 since we are working with 0-based array indices v.sendMessage(ChatColor.BLUE + "Water level set to " + ChatColor.GREEN + (waterLevel + 1)); // +1 since we are working with 0-based array indices
} } else if (parameter.equalsIgnoreCase("-cfloor") || parameter.equalsIgnoreCase("-coverfloor")) {
else if (parameter.equalsIgnoreCase("-cfloor") || parameter.equalsIgnoreCase("-coverfloor")) if ((i + 1) >= par.length) {
{
if ((i + 1) >= par.length)
{
v.sendMessage(ChatColor.RED + "Missing parameter. Correct syntax: -cfloor [y|n] (e.g. -cfloor y)"); v.sendMessage(ChatColor.RED + "Missing parameter. Correct syntax: -cfloor [y|n] (e.g. -cfloor y)");
continue; continue;
} }
@ -166,9 +138,7 @@ public class OceanBrush extends Brush
this.coverFloor = par[++i].equalsIgnoreCase("y"); this.coverFloor = par[++i].equalsIgnoreCase("y");
v.sendMessage(ChatColor.BLUE + String.format("Floor cover %s.", ChatColor.GREEN + (this.coverFloor ? "enabled" : "disabled"))); v.sendMessage(ChatColor.BLUE + String.format("Floor cover %s.", ChatColor.GREEN + (this.coverFloor ? "enabled" : "disabled")));
} }
} } catch (Exception exception) {
catch (Exception exception)
{
v.sendMessage(ChatColor.RED + String.format("Error while parsing parameter: %s", parameter)); v.sendMessage(ChatColor.RED + String.format("Error while parsing parameter: %s", parameter));
exception.printStackTrace(); exception.printStackTrace();
} }
@ -176,16 +146,14 @@ public class OceanBrush extends Brush
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.BLUE + "Water level set to " + ChatColor.GREEN + (waterLevel + 1)); // +1 since we are working with 0-based array indices vm.custom(ChatColor.BLUE + "Water level set to " + ChatColor.GREEN + (waterLevel + 1)); // +1 since we are working with 0-based array indices
vm.custom(ChatColor.BLUE + String.format("Floor cover %s.", ChatColor.GREEN + (this.coverFloor ? "enabled" : "disabled"))); vm.custom(ChatColor.BLUE + String.format("Floor cover %s.", ChatColor.GREEN + (this.coverFloor ? "enabled" : "disabled")));
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.ocean"; return "voxelsniper.brush.ocean";
} }
} }

Datei anzeigen

@ -9,7 +9,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#The_Overlay_.2F_Topsoil_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Overlay_.2F_Topsoil_Brush
@ -38,24 +37,24 @@ public class OverlayBrush extends PerformBrush {
// check if column is valid // check if column is valid
// column is valid if it has no solid block right above the clicked layer // column is valid if it has no solid block right above the clicked layer
final int materialId = this.getBlockIdAt(this.getTargetBlock().getX() + x, final int materialId = this.getBlockIdAt(this.getTargetBlock().getX() + x,
this.getTargetBlock().getY() + 1, this.getTargetBlock().getZ() + z); this.getTargetBlock().getY() + 1, this.getTargetBlock().getZ() + z);
if (isIgnoredBlock(materialId)) { if (isIgnoredBlock(materialId)) {
if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared) { if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared) {
for (int y = this.getTargetBlock().getY(); y > 0; y--) { for (int y = this.getTargetBlock().getY(); y > 0; y--) {
// check for surface // check for surface
final int layerBlockId = final int layerBlockId =
this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getBlockIdAt(this.getTargetBlock().getX() + x, y,
this.getTargetBlock().getZ() + z); this.getTargetBlock().getZ() + z);
if (!isIgnoredBlock(layerBlockId)) { if (!isIgnoredBlock(layerBlockId)) {
for (int currentDepth = y; for (int currentDepth = y;
y - currentDepth < depth; currentDepth--) { y - currentDepth < depth; currentDepth--) {
final int currentBlockId = final int currentBlockId =
this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getBlockIdAt(this.getTargetBlock().getX() + x,
currentDepth, this.getTargetBlock().getZ() + z); currentDepth, this.getTargetBlock().getZ() + z);
if (isOverrideableMaterial(currentBlockId)) { if (isOverrideableMaterial(currentBlockId)) {
this.current.perform( this.current.perform(
this.clampY(this.getTargetBlock().getX() + x, this.clampY(this.getTargetBlock().getX() + x,
currentDepth, this.getTargetBlock().getZ() + z)); currentDepth, this.getTargetBlock().getZ() + z));
} }
} }
break; break;
@ -69,7 +68,8 @@ public class OverlayBrush extends PerformBrush {
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
@SuppressWarnings("deprecation") private boolean isIgnoredBlock(int materialId) { @SuppressWarnings("deprecation")
private boolean isIgnoredBlock(int materialId) {
BlockType type = BlockTypes.get(materialId); BlockType type = BlockTypes.get(materialId);
switch (type.getInternalId()) { switch (type.getInternalId()) {
case BlockID.WATER: case BlockID.WATER:
@ -82,7 +82,8 @@ public class OverlayBrush extends PerformBrush {
} }
} }
@SuppressWarnings("deprecation") private boolean isOverrideableMaterial(int materialId) { @SuppressWarnings("deprecation")
private boolean isOverrideableMaterial(int materialId) {
BlockMaterial mat = BlockTypes.get(materialId).getMaterial(); BlockMaterial mat = BlockTypes.get(materialId).getMaterial();
if (allBlocks && !(mat.isAir())) { if (allBlocks && !(mat.isAir())) {
return true; return true;
@ -102,32 +103,32 @@ public class OverlayBrush extends PerformBrush {
for (int y = this.getTargetBlock().getY(); for (int y = this.getTargetBlock().getY();
y > 0 && !surfaceFound; y--) { // start scanning from the height you clicked at y > 0 && !surfaceFound; y--) { // start scanning from the height you clicked at
if (memory[x + brushSize][z + brushSize] if (memory[x + brushSize][z + brushSize]
!= 1) { // if haven't already found the surface in this column != 1) { // if haven't already found the surface in this column
if ((Math.pow(x, 2) + Math.pow(z, 2)) if ((Math.pow(x, 2) + Math.pow(z, 2))
<= brushSizeSquared) { // if inside of the column... <= brushSizeSquared) { // if inside of the column...
if (!this.getBlockAt(this.getTargetBlock().getX() + x, y - 1, if (!this.getBlockAt(this.getTargetBlock().getX() + x, y - 1,
this.getTargetBlock().getZ() + z)
.isEmpty()) { // if not a floating block (like one of Notch'world pools)
if (this.getBlockAt(this.getTargetBlock().getX() + x, y + 1,
this.getTargetBlock().getZ() + z) this.getTargetBlock().getZ() + z)
.isEmpty()) { // must start at surface... this prevents it filling stuff in if .isEmpty()) { // if not a floating block (like one of Notch'world pools)
if (this.getBlockAt(this.getTargetBlock().getX() + x, y + 1,
this.getTargetBlock().getZ() + z)
.isEmpty()) { // must start at surface... this prevents it filling stuff in if
// you click in a wall and it starts out below surface. // you click in a wall and it starts out below surface.
if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff. if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
BlockType type = BukkitAdapter.asBlockType((this BlockType type = BukkitAdapter.asBlockType((this
.getBlockType(this.getTargetBlock().getX() + x, y, .getBlockType(this.getTargetBlock().getX() + x, y,
this.getTargetBlock().getZ() + z))); this.getTargetBlock().getZ() + z)));
BlockMaterial mat = type.getMaterial(); BlockMaterial mat = type.getMaterial();
if (mat.isSolid() && mat.isFullCube() && !mat if (mat.isSolid() && mat.isFullCube() && !mat
.hasContainer()) { .hasContainer()) {
for (int d = 1; (d < this.depth + 1); d++) { for (int d = 1; (d < this.depth + 1); d++) {
this.current.perform( this.current.perform(
this.clampY(this.getTargetBlock().getX() + x, this.clampY(this.getTargetBlock().getX() + x,
y + d, this.getTargetBlock().getZ() y + d, this.getTargetBlock().getZ()
+ z)); // fills down as many layers as you specify + z)); // fills down as many layers as you specify
// in parameters // in parameters
memory[x + brushSize][z + brushSize] = memory[x + brushSize][z + brushSize] =
1; // stop it from checking any other blocks in this vertical 1x1 column. 1; // stop it from checking any other blocks in this vertical 1x1 column.
} }
surfaceFound = true; surfaceFound = true;
@ -135,12 +136,12 @@ public class OverlayBrush extends PerformBrush {
} else { } else {
for (int d = 1; (d < this.depth + 1); d++) { for (int d = 1; (d < this.depth + 1); d++) {
this.current.perform( this.current.perform(
this.clampY(this.getTargetBlock().getX() + x, y + d, this.clampY(this.getTargetBlock().getX() + x, y + d,
this.getTargetBlock().getZ() this.getTargetBlock().getZ()
+ z)); // fills down as many layers as you specify in + z)); // fills down as many layers as you specify in
// parameters // parameters
memory[x + brushSize][z + brushSize] = memory[x + brushSize][z + brushSize] =
1; // stop it from checking any other blocks in this vertical 1x1 column. 1; // stop it from checking any other blocks in this vertical 1x1 column.
} }
surfaceFound = true; surfaceFound = true;
} }
@ -156,29 +157,33 @@ public class OverlayBrush extends PerformBrush {
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
@Override protected final void arrow(final SnipeData v) { @Override
protected final void arrow(final SnipeData v) {
this.overlay(v); this.overlay(v);
} }
@Override protected final void powder(final SnipeData v) { @Override
protected final void powder(final SnipeData v) {
this.overlayTwo(v); this.overlayTwo(v);
} }
@Override public final void info(final Message vm) { @Override
public final void info(final Message vm) {
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override public final void parameters(final String[] par, final SnipeData v) { @Override
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) { for (int i = 1; i < par.length; i++) {
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) { if (parameter.equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Overlay brush parameters:"); v.sendMessage(ChatColor.GOLD + "Overlay brush parameters:");
v.sendMessage(ChatColor.AQUA v.sendMessage(ChatColor.AQUA
+ "d[number] (ex: d3) How many blocks deep you want to replace from the surface."); + "d[number] (ex: d3) How many blocks deep you want to replace from the surface.");
v.sendMessage(ChatColor.BLUE v.sendMessage(ChatColor.BLUE
+ "all (ex: /b over all) Sets the brush to overlay over ALL materials, not just natural surface ones (will no longer ignore trees and buildings). The parameter /some will set it back to default."); + "all (ex: /b over all) Sets the brush to overlay over ALL materials, not just natural surface ones (will no longer ignore trees and buildings). The parameter /some will set it back to default.");
return; return;
} }
if (parameter.startsWith("d")) { if (parameter.startsWith("d")) {
@ -199,15 +204,16 @@ public class OverlayBrush extends PerformBrush {
} else if (parameter.startsWith("some")) { } else if (parameter.startsWith("some")) {
this.allBlocks = false; this.allBlocks = false;
v.sendMessage( v.sendMessage(
ChatColor.BLUE + "Will overlay only natural block types." + this.depth); ChatColor.BLUE + "Will overlay only natural block types." + this.depth);
} else { } else {
v.sendMessage(ChatColor.RED v.sendMessage(ChatColor.RED
+ "Invalid brush parameters! use the info parameter to display parameter info."); + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override public String getPermissionNode() { @Override
public String getPermissionNode() {
return "voxelsniper.brush.overlay"; return "voxelsniper.brush.overlay";
} }
} }

Datei anzeigen

@ -10,13 +10,11 @@ import com.thevoxelbox.voxelsniper.SnipeData;
* *
* @author Voxel * @author Voxel
*/ */
public class PaintingBrush extends Brush public class PaintingBrush extends Brush {
{
/** /**
* *
*/ */
public PaintingBrush() public PaintingBrush() {
{
this.setName("Painting"); this.setName("Painting");
} }
@ -26,8 +24,7 @@ public class PaintingBrush extends Brush
* @param v Sniper caller * @param v Sniper caller
*/ */
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
PaintingWrapper.paint(v.owner().getPlayer(), true, false, 0); PaintingWrapper.paint(v.owner().getPlayer(), true, false, 0);
} }
@ -37,20 +34,17 @@ public class PaintingBrush extends Brush
* @param v Sniper caller * @param v Sniper caller
*/ */
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
PaintingWrapper.paint(v.owner().getPlayer(), true, true, 0); PaintingWrapper.paint(v.owner().getPlayer(), true, true, 0);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.painting"; return "voxelsniper.brush.painting";
} }
} }

Datei anzeigen

@ -5,15 +5,13 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import java.util.HashSet; import java.util.HashSet;
/** /**
* @author Piotr * @author Piotr
*/ */
public class PullBrush extends Brush public class PullBrush extends Brush {
{
private final HashSet<BlockWrapper> surface = new HashSet<>(); private final HashSet<BlockWrapper> surface = new HashSet<>();
private int vh; private int vh;
private double c1 = 1; private double c1 = 1;
@ -22,14 +20,12 @@ public class PullBrush extends Brush
/** /**
* Default Constructor. * Default Constructor.
*/ */
public PullBrush() public PullBrush() {
{
this.setName("Soft Selection"); this.setName("Soft Selection");
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.height(); vm.height();
@ -38,17 +34,13 @@ public class PullBrush extends Brush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ try {
try
{
final double pinch = Double.parseDouble(par[1]); final double pinch = Double.parseDouble(par[1]);
final double bubble = Double.parseDouble(par[2]); final double bubble = Double.parseDouble(par[2]);
this.c1 = 1 - pinch; this.c1 = 1 - pinch;
this.c2 = bubble; this.c2 = bubble;
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters!"); v.sendMessage(ChatColor.RED + "Invalid brush parameters!");
} }
} }
@ -57,8 +49,7 @@ public class PullBrush extends Brush
* @param t * @param t
* @return double * @return double
*/ */
private double getStr(final double t) private double getStr(final double t) {
{
final double lt = 1 - t; final double lt = 1 - t;
return (lt * lt * lt) + 3 * (lt * lt) * t * this.c1 + 3 * lt * (t * t) * this.c2; // My + (t * ((By + (t * ((c2 + (t * (0 - c2))) - By))) - My)); return (lt * lt * lt) + 3 * (lt * lt) * t * this.c1 + 3 * lt * (t * t) * this.c2; // My + (t * ((By + (t * ((c2 + (t * (0 - c2))) - By))) - My));
} }
@ -66,26 +57,20 @@ public class PullBrush extends Brush
/** /**
* @param v * @param v
*/ */
private void getSurface(final SnipeData v) private void getSurface(final SnipeData v) {
{
this.surface.clear(); this.surface.clear();
final double bSquared = Math.pow(v.getBrushSize() + 0.5, 2); final double bSquared = Math.pow(v.getBrushSize() + 0.5, 2);
for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) {
{
final double zSquared = Math.pow(z, 2); final double zSquared = Math.pow(z, 2);
final int actualZ = this.getTargetBlock().getZ() + z; final int actualZ = this.getTargetBlock().getZ() + z;
for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
final int actualX = this.getTargetBlock().getX() + x; final int actualX = this.getTargetBlock().getX() + x;
for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++) for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++) {
{
final double volume = (xSquared + Math.pow(y, 2) + zSquared); final double volume = (xSquared + Math.pow(y, 2) + zSquared);
if (volume <= bSquared) if (volume <= bSquared) {
{ if (this.isSurface(actualX, this.getTargetBlock().getY() + y, actualZ)) {
if (this.isSurface(actualX, this.getTargetBlock().getY() + y, actualZ))
{
this.surface.add(new BlockWrapper(this.clampY(actualX, this.getTargetBlock().getY() + y, actualZ), this.getStr(((volume / bSquared))))); this.surface.add(new BlockWrapper(this.clampY(actualX, this.getTargetBlock().getY() + y, actualZ), this.getStr(((volume / bSquared)))));
} }
} }
@ -100,31 +85,24 @@ public class PullBrush extends Brush
* @param z * @param z
* @return boolean * @return boolean
*/ */
private boolean isSurface(final int x, final int y, final int z) private boolean isSurface(final int x, final int y, final int z) {
{
return !this.getBlockAt(x, y, z).isEmpty() && ((this.getBlockAt(x, y - 1, z).isEmpty()) || (this.getBlockAt(x, y + 1, z).isEmpty()) || (this.getBlockAt(x + 1, y, z).isEmpty()) || (this.getBlockAt(x - 1, y, z).isEmpty()) || (this.getBlockAt(x, y, z + 1).isEmpty()) || (this.getBlockAt(x, y, z - 1).isEmpty())); return !this.getBlockAt(x, y, z).isEmpty() && ((this.getBlockAt(x, y - 1, z).isEmpty()) || (this.getBlockAt(x, y + 1, z).isEmpty()) || (this.getBlockAt(x + 1, y, z).isEmpty()) || (this.getBlockAt(x - 1, y, z).isEmpty()) || (this.getBlockAt(x, y, z + 1).isEmpty()) || (this.getBlockAt(x, y, z - 1).isEmpty()));
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void setBlock(final BlockWrapper block) private void setBlock(final BlockWrapper block) {
{
final AsyncBlock currentBlock = this.clampY(block.getX(), block.getY() + (int) (this.vh * block.getStr()), block.getZ()); final AsyncBlock currentBlock = this.clampY(block.getX(), block.getY() + (int) (this.vh * block.getStr()), block.getZ());
if (this.getBlockAt(block.getX(), block.getY() - 1, block.getZ()).isEmpty()) if (this.getBlockAt(block.getX(), block.getY() - 1, block.getZ()).isEmpty()) {
{
currentBlock.setTypeId(block.getId()); currentBlock.setTypeId(block.getId());
currentBlock.setPropertyId(block.getD()); currentBlock.setPropertyId(block.getD());
for (int y = block.getY(); y < currentBlock.getY(); y++) for (int y = block.getY(); y < currentBlock.getY(); y++) {
{
this.setBlockIdAt(block.getZ(), block.getX(), y, BlockTypes.AIR.getInternalId()); this.setBlockIdAt(block.getZ(), block.getX(), y, BlockTypes.AIR.getInternalId());
} }
} } else {
else
{
currentBlock.setTypeId(block.getId()); currentBlock.setTypeId(block.getId());
currentBlock.setPropertyId(block.getD()); currentBlock.setPropertyId(block.getD());
for (int y = block.getY() - 1; y < currentBlock.getY(); y++) for (int y = block.getY() - 1; y < currentBlock.getY(); y++) {
{
final AsyncBlock current = this.clampY(block.getX(), y, block.getZ()); final AsyncBlock current = this.clampY(block.getX(), y, block.getZ());
current.setTypeId(block.getId()); current.setTypeId(block.getId());
current.setPropertyId(block.getD()); current.setPropertyId(block.getD());
@ -133,44 +111,35 @@ public class PullBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void setBlockDown(final BlockWrapper block) private void setBlockDown(final BlockWrapper block) {
{
final AsyncBlock currentBlock = this.clampY(block.getX(), block.getY() + (int) (this.vh * block.getStr()), block.getZ()); final AsyncBlock currentBlock = this.clampY(block.getX(), block.getY() + (int) (this.vh * block.getStr()), block.getZ());
currentBlock.setTypeId(block.getId()); currentBlock.setTypeId(block.getId());
currentBlock.setPropertyId(block.getD()); currentBlock.setPropertyId(block.getD());
for (int y = block.getY(); y > currentBlock.getY(); y--) for (int y = block.getY(); y > currentBlock.getY(); y--) {
{
this.setBlockIdAt(block.getZ(), block.getX(), y, BlockTypes.AIR.getInternalId()); this.setBlockIdAt(block.getZ(), block.getX(), y, BlockTypes.AIR.getInternalId());
} }
// } // }
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.vh = v.getVoxelHeight(); this.vh = v.getVoxelHeight();
this.getSurface(v); this.getSurface(v);
if (this.vh > 0) if (this.vh > 0) {
{ for (final BlockWrapper block : this.surface) {
for (final BlockWrapper block : this.surface)
{
this.setBlock(block); this.setBlock(block);
} }
} } else if (this.vh < 0) {
else if (this.vh < 0) for (final BlockWrapper block : this.surface) {
{
for (final BlockWrapper block : this.surface)
{
this.setBlockDown(block); this.setBlockDown(block);
} }
} }
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.vh = v.getVoxelHeight(); this.vh = v.getVoxelHeight();
this.surface.clear(); this.surface.clear();
@ -184,32 +153,27 @@ public class PullBrush extends Brush
int id; int id;
// Are we pulling up ? // Are we pulling up ?
if (this.vh > 0) if (this.vh > 0) {
{
// Z - Axis // Z - Axis
for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) {
{
final int zSquared = z * z; final int zSquared = z * z;
final int actualZ = this.getTargetBlock().getZ() + z; final int actualZ = this.getTargetBlock().getZ() + z;
// X - Axis // X - Axis
for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) {
{
final int xSquared = x * x; final int xSquared = x * x;
final int actualX = this.getTargetBlock().getX() + x; final int actualX = this.getTargetBlock().getX() + x;
// Down the Y - Axis // Down the Y - Axis
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) {
{
final double volume = zSquared + xSquared + (y * y); final double volume = zSquared + xSquared + (y * y);
// Is this in the range of the brush? // Is this in the range of the brush?
if (volume <= brushSizeSquared && !this.getWorld().getBlockAt(actualX, this.getTargetBlock().getY() + y, actualZ).isEmpty()) if (volume <= brushSizeSquared && !this.getWorld().getBlockAt(actualX, this.getTargetBlock().getY() + y, actualZ).isEmpty()) {
{
int actualY = this.getTargetBlock().getY() + y; int actualY = this.getTargetBlock().getY() + y;
@ -220,22 +184,18 @@ public class PullBrush extends Brush
this.clampY(actualX, lastY, actualZ).setTypeId(this.getWorld().getBlockAt(actualX, actualY, actualZ).getTypeId()); this.clampY(actualX, lastY, actualZ).setTypeId(this.getWorld().getBlockAt(actualX, actualY, actualZ).getTypeId());
if (str == 1) if (str == 1) {
{
str = 0.8; str = 0.8;
} }
while (lastStr > 0) while (lastStr > 0) {
{ if (actualY < this.getTargetBlock().getY()) {
if (actualY < this.getTargetBlock().getY())
{
str = str * str; str = str * str;
} }
lastStr = (int) (this.vh * str); lastStr = (int) (this.vh * str);
newY = actualY + lastStr; newY = actualY + lastStr;
id = this.getWorld().getBlockAt(actualX, actualY, actualZ).getTypeId(); id = this.getWorld().getBlockAt(actualX, actualY, actualZ).getTypeId();
for (int i = newY; i < lastY; i++) for (int i = newY; i < lastY; i++) {
{
this.clampY(actualX, i, actualZ).setTypeId(id); this.clampY(actualX, i, actualZ).setTypeId(id);
} }
lastY = newY; lastY = newY;
@ -246,33 +206,25 @@ public class PullBrush extends Brush
} }
} }
} }
} } else {
else for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++) {
{
for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++)
{
final double zSquared = Math.pow(z, 2); final double zSquared = Math.pow(z, 2);
final int actualZ = this.getTargetBlock().getZ() + z; final int actualZ = this.getTargetBlock().getZ() + z;
for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) for (int x = -v.getBrushSize(); x <= v.getBrushSize(); x++) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
final int actualX = this.getTargetBlock().getX() + x; final int actualX = this.getTargetBlock().getX() + x;
for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++) for (int y = -v.getBrushSize(); y <= v.getBrushSize(); y++) {
{
double volume = (xSquared + Math.pow(y, 2) + zSquared); double volume = (xSquared + Math.pow(y, 2) + zSquared);
if (volume <= brushSizeSquared && !this.getWorld().getBlockAt(actualX, this.getTargetBlock().getY() + y, actualZ).isEmpty()) if (volume <= brushSizeSquared && !this.getWorld().getBlockAt(actualX, this.getTargetBlock().getY() + y, actualZ).isEmpty()) {
{
final int actualY = this.getTargetBlock().getY() + y; final int actualY = this.getTargetBlock().getY() + y;
lastY = actualY + (int) (this.vh * this.getStr(volume / brushSizeSquared)); lastY = actualY + (int) (this.vh * this.getStr(volume / brushSizeSquared));
this.clampY(actualX, lastY, actualZ).setTypeId(this.getWorld().getBlockAt(actualX, actualY, actualZ).getTypeId()); this.clampY(actualX, lastY, actualZ).setTypeId(this.getWorld().getBlockAt(actualX, actualY, actualZ).getTypeId());
y++; y++;
volume = (xSquared + Math.pow(y, 2) + zSquared); volume = (xSquared + Math.pow(y, 2) + zSquared);
while (volume <= brushSizeSquared) while (volume <= brushSizeSquared) {
{
final int blockY = this.getTargetBlock().getY() + y + (int) (this.vh * this.getStr(volume / brushSizeSquared)); final int blockY = this.getTargetBlock().getY() + y + (int) (this.vh * this.getStr(volume / brushSizeSquared));
final int blockId = this.getWorld().getBlockAt(actualX, this.getTargetBlock().getY() + y, actualZ).getTypeId(); final int blockId = this.getWorld().getBlockAt(actualX, this.getTargetBlock().getY() + y, actualZ).getTypeId();
for (int i = blockY; i < lastY; i++) for (int i = blockY; i < lastY; i++) {
{
this.clampY(actualX, i, actualZ).setTypeId(blockId); this.clampY(actualX, i, actualZ).setTypeId(blockId);
} }
lastY = blockY; lastY = blockY;
@ -287,11 +239,15 @@ public class PullBrush extends Brush
} }
} }
@Override
public String getPermissionNode() {
return "voxelsniper.brush.pull";
}
/** /**
* @author Piotr * @author Piotr
*/ */
private final class BlockWrapper private final class BlockWrapper {
{
private final int id; private final int id;
private final int d; private final int d;
@ -305,8 +261,7 @@ public class PullBrush extends Brush
* @param st * @param st
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public BlockWrapper(final AsyncBlock block, final double st) public BlockWrapper(final AsyncBlock block, final double st) {
{
this.id = block.getTypeId(); this.id = block.getTypeId();
this.d = block.getPropertyId(); this.d = block.getPropertyId();
this.x = block.getX(); this.x = block.getX();
@ -318,55 +273,43 @@ public class PullBrush extends Brush
/** /**
* @return the d * @return the d
*/ */
public int getD() public int getD() {
{
return this.d; return this.d;
} }
/** /**
* @return the id * @return the id
*/ */
public int getId() public int getId() {
{
return this.id; return this.id;
} }
/** /**
* @return the str * @return the str
*/ */
public double getStr() public double getStr() {
{
return this.str; return this.str;
} }
/** /**
* @return the x * @return the x
*/ */
public int getX() public int getX() {
{
return this.x; return this.x;
} }
/** /**
* @return the y * @return the y
*/ */
public int getY() public int getY() {
{
return this.y; return this.y;
} }
/** /**
* @return the z * @return the z
*/ */
public int getZ() public int getZ() {
{
return this.z; return this.z;
} }
} }
@Override
public String getPermissionNode()
{
return "voxelsniper.brush.pull";
}
} }

Datei anzeigen

@ -26,8 +26,7 @@ import java.util.Random;
* @author Deamon * @author Deamon
* @author MikeMatrix * @author MikeMatrix
*/ */
public class PunishBrush extends PerformBrush public class PunishBrush extends PerformBrush {
{
private static final int MAXIMAL_RANDOM_TELEPORTATION_RANGE = 400; private static final int MAXIMAL_RANDOM_TELEPORTATION_RANGE = 400;
private static final int TICKS_PER_SECOND = 20; private static final int TICKS_PER_SECOND = 20;
private static final int INFINIPUNISH_SIZE = -3; private static final int INFINIPUNISH_SIZE = -3;
@ -44,16 +43,13 @@ public class PunishBrush extends PerformBrush
/** /**
* Default Constructor. * Default Constructor.
*/ */
public PunishBrush() public PunishBrush() {
{
this.setName("Punish"); this.setName("Punish");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void applyPunishment(final LivingEntity entity, final SnipeData v) private void applyPunishment(final LivingEntity entity, final SnipeData v) {
{ switch (this.punishment) {
switch (this.punishment)
{
case FIRE: case FIRE:
entity.setFireTicks(PunishBrush.TICKS_PER_SECOND * this.punishDuration); entity.setFireTicks(PunishBrush.TICKS_PER_SECOND * this.punishDuration);
break; break;
@ -153,21 +149,16 @@ public class PunishBrush extends PerformBrush
entity.setVelocity(direction); entity.setVelocity(direction);
break; break;
case HYPNO: case HYPNO:
if (entity instanceof Player) if (entity instanceof Player) {
{
final Location location = entity.getLocation(); final Location location = entity.getLocation();
Location target = location.clone(); Location target = location.clone();
for (int z = this.punishLevel; z >= -this.punishLevel; z--) for (int z = this.punishLevel; z >= -this.punishLevel; z--) {
{ for (int x = this.punishLevel; x >= -this.punishLevel; x--) {
for (int x = this.punishLevel; x >= -this.punishLevel; x--) for (int y = this.punishLevel; y >= -this.punishLevel; y--) {
{
for (int y = this.punishLevel; y >= -this.punishLevel; y--)
{
target.setX(location.getX() + x); target.setX(location.getX() + x);
target.setY(location.getY() + y); target.setY(location.getY() + y);
target.setZ(location.getZ() + z); target.setZ(location.getZ() + z);
if (this.hypnoAffectLandscape && target.getBlock().isEmpty()) if (this.hypnoAffectLandscape && target.getBlock().isEmpty()) {
{
continue; continue;
} }
target = location.clone(); target = location.clone();
@ -187,10 +178,8 @@ public class PunishBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ if (!v.owner().getPlayer().hasPermission("voxelsniper.punish")) {
if (!v.owner().getPlayer().hasPermission("voxelsniper.punish"))
{
v.sendMessage("The server says no!"); v.sendMessage("The server says no!");
return; return;
} }
@ -198,11 +187,9 @@ public class PunishBrush extends PerformBrush
this.punishDuration = v.getVoxelHeight(); this.punishDuration = v.getVoxelHeight();
this.punishLevel = v.getcCen(); this.punishLevel = v.getcCen();
if (this.specificPlayer) if (this.specificPlayer) {
{
final Player punishedPlayer = Bukkit.getPlayer(this.punishPlayerName); final Player punishedPlayer = Bukkit.getPlayer(this.punishPlayerName);
if (punishedPlayer == null) if (punishedPlayer == null) {
{
v.sendMessage("No player " + this.punishPlayerName + " found."); v.sendMessage("No player " + this.punishPlayerName + " found.");
return; return;
} }
@ -216,29 +203,20 @@ public class PunishBrush extends PerformBrush
final List<LivingEntity> entities = v.getWorld().getLivingEntities(); final List<LivingEntity> entities = v.getWorld().getLivingEntities();
int numPunishApps = 0; int numPunishApps = 0;
for (final LivingEntity entity : entities) for (final LivingEntity entity : entities) {
{ if (v.owner().getPlayer() != entity || hitsSelf) {
if (v.owner().getPlayer() != entity || hitsSelf) if (v.getBrushSize() >= 0) {
{ try {
if (v.getBrushSize() >= 0) if (entity.getLocation().distanceSquared(targetLocation) <= brushSizeSquare) {
{
try
{
if (entity.getLocation().distanceSquared(targetLocation) <= brushSizeSquare)
{
numPunishApps++; numPunishApps++;
this.applyPunishment(entity, v); this.applyPunishment(entity, v);
} }
} } catch (final Exception exception) {
catch (final Exception exception)
{
exception.printStackTrace(); exception.printStackTrace();
v.sendMessage("An error occured."); v.sendMessage("An error occured.");
return; return;
} }
} } else if (v.getBrushSize() == PunishBrush.INFINIPUNISH_SIZE) {
else if (v.getBrushSize() == PunishBrush.INFINIPUNISH_SIZE)
{
numPunishApps++; numPunishApps++;
this.applyPunishment(entity, v); this.applyPunishment(entity, v);
} }
@ -248,10 +226,8 @@ public class PunishBrush extends PerformBrush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (!v.owner().getPlayer().hasPermission("voxelsniper.punish")) {
if (!v.owner().getPlayer().hasPermission("voxelsniper.punish"))
{
v.sendMessage("The server says no!"); v.sendMessage("The server says no!");
return; return;
} }
@ -261,10 +237,8 @@ public class PunishBrush extends PerformBrush
final List<LivingEntity> entities = v.getWorld().getLivingEntities(); final List<LivingEntity> entities = v.getWorld().getLivingEntities();
for (final LivingEntity entity : entities) for (final LivingEntity entity : entities) {
{ if (entity.getLocation().distanceSquared(targetLocation) < brushSizeSquare) {
if (entity.getLocation().distanceSquared(targetLocation) < brushSizeSquare)
{
entity.setFireTicks(0); entity.setFireTicks(0);
entity.removePotionEffect(PotionEffectType.BLINDNESS); entity.removePotionEffect(PotionEffectType.BLINDNESS);
entity.removePotionEffect(PotionEffectType.CONFUSION); entity.removePotionEffect(PotionEffectType.CONFUSION);
@ -276,8 +250,7 @@ public class PunishBrush extends PerformBrush
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.GREEN + "Punishment: " + this.punishment.toString()); vm.custom(ChatColor.GREEN + "Punishment: " + this.punishment.toString());
vm.size(); vm.size();
@ -285,14 +258,11 @@ public class PunishBrush extends PerformBrush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i].toLowerCase(); final String parameter = par[i].toLowerCase();
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Punish Brush Options:"); v.sendMessage(ChatColor.GOLD + "Punish Brush Options:");
v.sendMessage(ChatColor.AQUA + "Punishments can be set via /b p [punishment]"); v.sendMessage(ChatColor.AQUA + "Punishments can be set via /b p [punishment]");
v.sendMessage(ChatColor.AQUA + "Punishment level can be set with /vc [level]"); v.sendMessage(ChatColor.AQUA + "Punishment level can be set with /vc [level]");
@ -302,57 +272,37 @@ public class PunishBrush extends PerformBrush
v.sendMessage(ChatColor.AQUA + "Parameter -toggleSelf will toggle whether you get hit as well."); v.sendMessage(ChatColor.AQUA + "Parameter -toggleSelf will toggle whether you get hit as well.");
v.sendMessage(ChatColor.AQUA + "Available Punishment Options:"); v.sendMessage(ChatColor.AQUA + "Available Punishment Options:");
final StringBuilder punishmentOptions = new StringBuilder(); final StringBuilder punishmentOptions = new StringBuilder();
for (final Punishment punishment : Punishment.values()) for (final Punishment punishment : Punishment.values()) {
{ if (punishmentOptions.length() != 0) {
if (punishmentOptions.length() != 0)
{
punishmentOptions.append(" | "); punishmentOptions.append(" | ");
} }
punishmentOptions.append(punishment.name()); punishmentOptions.append(punishment.name());
} }
v.sendMessage(ChatColor.GOLD + punishmentOptions.toString()); v.sendMessage(ChatColor.GOLD + punishmentOptions.toString());
return; return;
} } else if (parameter.equalsIgnoreCase("-toggleSM")) {
else if (parameter.equalsIgnoreCase("-toggleSM"))
{
this.specificPlayer = !this.specificPlayer; this.specificPlayer = !this.specificPlayer;
if (this.specificPlayer) if (this.specificPlayer) {
{ try {
try
{
this.punishPlayerName = par[++i]; this.punishPlayerName = par[++i];
} } catch (final IndexOutOfBoundsException exception) {
catch (final IndexOutOfBoundsException exception)
{
v.sendMessage(ChatColor.AQUA + "You have to specify a player name after -toggleSM if you want to turn the specific player feature on."); v.sendMessage(ChatColor.AQUA + "You have to specify a player name after -toggleSM if you want to turn the specific player feature on.");
} }
} }
} } else if (parameter.equalsIgnoreCase("-toggleSelf")) {
else if (parameter.equalsIgnoreCase("-toggleSelf"))
{
this.hitsSelf = !this.hitsSelf; this.hitsSelf = !this.hitsSelf;
if (hitsSelf) if (hitsSelf) {
{
v.sendMessage(ChatColor.AQUA + "Your punishments will now affect you too!"); v.sendMessage(ChatColor.AQUA + "Your punishments will now affect you too!");
} } else {
else
{
v.sendMessage(ChatColor.AQUA + "Your punishments will no longer affect you!"); v.sendMessage(ChatColor.AQUA + "Your punishments will no longer affect you!");
} }
} } else if (parameter.equalsIgnoreCase("-toggleHypnoLandscape")) {
else if (parameter.equalsIgnoreCase("-toggleHypnoLandscape"))
{
this.hypnoAffectLandscape = !this.hypnoAffectLandscape; this.hypnoAffectLandscape = !this.hypnoAffectLandscape;
} } else {
else try {
{
try
{
this.punishment = Punishment.valueOf(parameter.toUpperCase()); this.punishment = Punishment.valueOf(parameter.toUpperCase());
v.sendMessage(ChatColor.AQUA + this.punishment.name().toLowerCase() + " punishment selected."); v.sendMessage(ChatColor.AQUA + this.punishment.name().toLowerCase() + " punishment selected.");
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception)
{
v.sendMessage(ChatColor.AQUA + "No such Punishment."); v.sendMessage(ChatColor.AQUA + "No such Punishment.");
} }
} }
@ -360,11 +310,15 @@ public class PunishBrush extends PerformBrush
} }
@Override
public String getPermissionNode() {
return "voxelsniper.brush.punish";
}
/** /**
* @author Monofraps * @author Monofraps
*/ */
private enum Punishment private enum Punishment {
{
// Monofraps // Monofraps
FIRE, LIGHTNING, BLINDNESS, DRUNK, KILL, RANDOMTP, ALL_POTION, FIRE, LIGHTNING, BLINDNESS, DRUNK, KILL, RANDOMTP, ALL_POTION,
// Deamon // Deamon
@ -373,10 +327,4 @@ public class PunishBrush extends PerformBrush
// MikeMatrix // MikeMatrix
FORCE, HYPNO FORCE, HYPNO
} }
@Override
public String getPermissionNode()
{
return "voxelsniper.brush.punish";
}
} }

Datei anzeigen

@ -5,7 +5,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.block.Block;
import java.util.Random; import java.util.Random;
@ -15,8 +14,7 @@ import java.util.Random;
* @author Piotr * @author Piotr
* @author Giltwist (Randomized blockPositionY) * @author Giltwist (Randomized blockPositionY)
*/ */
public class RandomErodeBrush extends Brush public class RandomErodeBrush extends Brush {
{
private final double trueCircle = 0.5; private final double trueCircle = 0.5;
private BlockWrapper[][][] snap; private BlockWrapper[][][] snap;
private BlockWrapper[][][] firstSnap; private BlockWrapper[][][] firstSnap;
@ -31,85 +29,64 @@ public class RandomErodeBrush extends Brush
/** /**
* *
*/ */
public RandomErodeBrush() public RandomErodeBrush() {
{
this.setName("RandomErode"); this.setName("RandomErode");
} }
private boolean erode(final int x, final int y, final int z) private boolean erode(final int x, final int y, final int z) {
{ if (this.snap[x][y][z].isSolid()) {
if (this.snap[x][y][z].isSolid())
{
int d = 0; int d = 0;
if (!this.snap[x + 1][y][z].isSolid()) if (!this.snap[x + 1][y][z].isSolid()) {
{
d++; d++;
} }
if (!this.snap[x - 1][y][z].isSolid()) if (!this.snap[x - 1][y][z].isSolid()) {
{
d++; d++;
} }
if (!this.snap[x][y + 1][z].isSolid()) if (!this.snap[x][y + 1][z].isSolid()) {
{
d++; d++;
} }
if (!this.snap[x][y - 1][z].isSolid()) if (!this.snap[x][y - 1][z].isSolid()) {
{
d++; d++;
} }
if (!this.snap[x][y][z + 1].isSolid()) if (!this.snap[x][y][z + 1].isSolid()) {
{
d++; d++;
} }
if (!this.snap[x][y][z - 1].isSolid()) if (!this.snap[x][y][z - 1].isSolid()) {
{
d++; d++;
} }
return (d >= this.erodeFace); return (d >= this.erodeFace);
} } else {
else
{
return false; return false;
} }
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private boolean fill(final int x, final int y, final int z) private boolean fill(final int x, final int y, final int z) {
{ if (this.snap[x][y][z].isSolid()) {
if (this.snap[x][y][z].isSolid())
{
return false; return false;
} } else {
else
{
int d = 0; int d = 0;
if (this.snap[x + 1][y][z].isSolid()) if (this.snap[x + 1][y][z].isSolid()) {
{
this.snap[x][y][z].setId(this.snap[x + 1][y][z].getNativeBlock().getTypeId()); this.snap[x][y][z].setId(this.snap[x + 1][y][z].getNativeBlock().getTypeId());
d++; d++;
} }
if (this.snap[x - 1][y][z].isSolid()) if (this.snap[x - 1][y][z].isSolid()) {
{
this.snap[x][y][z].setId(this.snap[x - 1][y][z].getNativeBlock().getTypeId()); this.snap[x][y][z].setId(this.snap[x - 1][y][z].getNativeBlock().getTypeId());
d++; d++;
} }
if (this.snap[x][y + 1][z].isSolid()) if (this.snap[x][y + 1][z].isSolid()) {
{
this.snap[x][y][z].setId(this.snap[x][y + 1][z].getNativeBlock().getTypeId()); this.snap[x][y][z].setId(this.snap[x][y + 1][z].getNativeBlock().getTypeId());
d++; d++;
} }
if (this.snap[x][y - 1][z].isSolid()) if (this.snap[x][y - 1][z].isSolid()) {
{
this.snap[x][y][z].setId(this.snap[x][y - 1][z].getNativeBlock().getTypeId()); this.snap[x][y][z].setId(this.snap[x][y - 1][z].getNativeBlock().getTypeId());
d++; d++;
} }
if (this.snap[x][y][z + 1].isSolid()) if (this.snap[x][y][z + 1].isSolid()) {
{
this.snap[x][y][z].setId(this.snap[x][y][z + 1].getNativeBlock().getTypeId()); this.snap[x][y][z].setId(this.snap[x][y][z + 1].getNativeBlock().getTypeId());
d++; d++;
} }
if (this.snap[x][y][z - 1].isSolid()) if (this.snap[x][y][z - 1].isSolid()) {
{
this.snap[x][y][z].setId(this.snap[x][y][z - 1].getNativeBlock().getTypeId()); this.snap[x][y][z].setId(this.snap[x][y][z - 1].getNativeBlock().getTypeId());
d++; d++;
} }
@ -117,26 +94,21 @@ public class RandomErodeBrush extends Brush
} }
} }
private void getMatrix() private void getMatrix() {
{
this.brushSize = ((this.bsize + 1) * 2) + 1; this.brushSize = ((this.bsize + 1) * 2) + 1;
if (this.snap.length == 0) if (this.snap.length == 0) {
{
this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize]; this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize];
int sx = this.getTargetBlock().getX() - (this.bsize + 1); int sx = this.getTargetBlock().getX() - (this.bsize + 1);
int sy = this.getTargetBlock().getY() - (this.bsize + 1); int sy = this.getTargetBlock().getY() - (this.bsize + 1);
int sz = this.getTargetBlock().getZ() - (this.bsize + 1); int sz = this.getTargetBlock().getZ() - (this.bsize + 1);
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
sz = this.getTargetBlock().getZ() - (this.bsize + 1); sz = this.getTargetBlock().getZ() - (this.bsize + 1);
for (int z = 0; z < this.snap.length; z++) for (int z = 0; z < this.snap.length; z++) {
{
sy = this.getTargetBlock().getY() - (this.bsize + 1); sy = this.getTargetBlock().getY() - (this.bsize + 1);
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{
this.snap[x][y][z] = new BlockWrapper(this.clampY(sx, sy, sz)); this.snap[x][y][z] = new BlockWrapper(this.clampY(sx, sy, sz));
sy++; sy++;
} }
@ -145,23 +117,18 @@ public class RandomErodeBrush extends Brush
sx++; sx++;
} }
this.firstSnap = this.snap.clone(); this.firstSnap = this.snap.clone();
} } else {
else
{
this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize]; this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize];
int sx = this.getTargetBlock().getX() - (this.bsize + 1); int sx = this.getTargetBlock().getX() - (this.bsize + 1);
int sy = this.getTargetBlock().getY() - (this.bsize + 1); int sy = this.getTargetBlock().getY() - (this.bsize + 1);
int sz = this.getTargetBlock().getZ() - (this.bsize + 1); int sz = this.getTargetBlock().getZ() - (this.bsize + 1);
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
sz = this.getTargetBlock().getZ() - (this.bsize + 1); sz = this.getTargetBlock().getZ() - (this.bsize + 1);
for (int z = 0; z < this.snap.length; z++) for (int z = 0; z < this.snap.length; z++) {
{
sy = this.getTargetBlock().getY() - (this.bsize + 1); sy = this.getTargetBlock().getY() - (this.bsize + 1);
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{
this.snap[x][y][z] = new BlockWrapper(this.clampY(sx, sy, sz)); this.snap[x][y][z] = new BlockWrapper(this.clampY(sx, sy, sz));
sy++; sy++;
} }
@ -173,32 +140,24 @@ public class RandomErodeBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void rerosion(final SnipeData v) private void rerosion(final SnipeData v) {
{
final Undo undo = new Undo(); final Undo undo = new Undo();
if (this.erodeFace >= 0 && this.erodeFace <= 6) if (this.erodeFace >= 0 && this.erodeFace <= 6) {
{ for (int currentErodeRecursion = 0; currentErodeRecursion < this.erodeRecursion; currentErodeRecursion++) {
for (int currentErodeRecursion = 0; currentErodeRecursion < this.erodeRecursion; currentErodeRecursion++)
{
this.getMatrix(); this.getMatrix();
final double brushSizeSquared = Math.pow(this.bsize + this.trueCircle, 2); final double brushSizeSquared = Math.pow(this.bsize + this.trueCircle, 2);
for (int z = 1; z < this.snap.length - 1; z++) for (int z = 1; z < this.snap.length - 1; z++) {
{
final double zSquared = Math.pow(z - (this.bsize + 1), 2); final double zSquared = Math.pow(z - (this.bsize + 1), 2);
for (int x = 1; x < this.snap.length - 1; x++) for (int x = 1; x < this.snap.length - 1; x++) {
{
final double xSquared = Math.pow(x - (this.bsize + 1), 2); final double xSquared = Math.pow(x - (this.bsize + 1), 2);
for (int y = 1; y < this.snap.length - 1; y++) for (int y = 1; y < this.snap.length - 1; y++) {
{
if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= brushSizeSquared)) if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= brushSizeSquared)) {
{ if (this.erode(x, y, z)) {
if (this.erode(x, y, z))
{
this.snap[x][y][z].getNativeBlock().setTypeId(BlockTypes.AIR.getInternalId()); this.snap[x][y][z].getNativeBlock().setTypeId(BlockTypes.AIR.getInternalId());
} }
} }
@ -207,29 +166,22 @@ public class RandomErodeBrush extends Brush
} }
} }
} }
if (this.fillFace >= 0 && this.fillFace <= 6) if (this.fillFace >= 0 && this.fillFace <= 6) {
{
final double brushSizeSquared = Math.pow(this.bsize + 0.5, 2); final double brushSizeSquared = Math.pow(this.bsize + 0.5, 2);
for (int currentFillRecursion = 0; currentFillRecursion < this.fillRecursion; currentFillRecursion++) for (int currentFillRecursion = 0; currentFillRecursion < this.fillRecursion; currentFillRecursion++) {
{
this.getMatrix(); this.getMatrix();
for (int z = 1; z < this.snap.length - 1; z++) for (int z = 1; z < this.snap.length - 1; z++) {
{
final double zSquared = Math.pow(z - (this.bsize + 1), 2); final double zSquared = Math.pow(z - (this.bsize + 1), 2);
for (int x = 1; x < this.snap.length - 1; x++) for (int x = 1; x < this.snap.length - 1; x++) {
{
final double xSquared = Math.pow(x - (this.bsize + 1), 2); final double xSquared = Math.pow(x - (this.bsize + 1), 2);
for (int y = 1; y < this.snap.length - 1; y++) for (int y = 1; y < this.snap.length - 1; y++) {
{
if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= brushSizeSquared)) if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= brushSizeSquared)) {
{ if (this.fill(x, y, z)) {
if (this.fill(x, y, z))
{
this.snap[x][y][z].getNativeBlock().setTypeId(this.snap[x][y][z].getId()); this.snap[x][y][z].getNativeBlock().setTypeId(this.snap[x][y][z].getId());
} }
} }
@ -239,14 +191,10 @@ public class RandomErodeBrush extends Brush
} }
} }
for (BlockWrapper[][] firstSnapSlice : this.firstSnap) for (BlockWrapper[][] firstSnapSlice : this.firstSnap) {
{ for (BlockWrapper[] firstSnapString : firstSnapSlice) {
for (BlockWrapper[] firstSnapString : firstSnapSlice) for (final BlockWrapper block : firstSnapString) {
{ if (block.getI() != block.getNativeBlock().getTypeId()) {
for (final BlockWrapper block : firstSnapString)
{
if (block.getI() != block.getNativeBlock().getTypeId())
{
undo.put(block.getNativeBlock()); undo.put(block.getNativeBlock());
} }
} }
@ -257,30 +205,22 @@ public class RandomErodeBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void rfilling(final SnipeData v) private void rfilling(final SnipeData v) {
{
final Undo undo = new Undo(); final Undo undo = new Undo();
if (this.fillFace >= 0 && this.fillFace <= 6) if (this.fillFace >= 0 && this.fillFace <= 6) {
{
final double bSquared = Math.pow(this.bsize + 0.5, 2); final double bSquared = Math.pow(this.bsize + 0.5, 2);
for (int currentFillRecursion = 0; currentFillRecursion < this.fillRecursion; currentFillRecursion++) for (int currentFillRecursion = 0; currentFillRecursion < this.fillRecursion; currentFillRecursion++) {
{
this.getMatrix(); this.getMatrix();
for (int z = 1; z < this.snap.length - 1; z++) for (int z = 1; z < this.snap.length - 1; z++) {
{
final double zSquared = Math.pow(z - (this.bsize + 1), 2); final double zSquared = Math.pow(z - (this.bsize + 1), 2);
for (int x = 1; x < this.snap.length - 1; x++) for (int x = 1; x < this.snap.length - 1; x++) {
{
final double xSquared = Math.pow(x - (this.bsize + 1), 2); final double xSquared = Math.pow(x - (this.bsize + 1), 2);
for (int y = 1; y < this.snap.length - 1; y++) for (int y = 1; y < this.snap.length - 1; y++) {
{ if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= bSquared)) {
if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= bSquared)) if (this.fill(x, y, z)) {
{
if (this.fill(x, y, z))
{
this.snap[x][y][z].getNativeBlock().setTypeId(this.snap[x][y][z].getId()); this.snap[x][y][z].getNativeBlock().setTypeId(this.snap[x][y][z].getId());
} }
} }
@ -289,29 +229,22 @@ public class RandomErodeBrush extends Brush
} }
} }
} }
if (this.erodeFace >= 0 && this.erodeFace <= 6) if (this.erodeFace >= 0 && this.erodeFace <= 6) {
{
final double bSquared = Math.pow(this.bsize + this.trueCircle, 2); final double bSquared = Math.pow(this.bsize + this.trueCircle, 2);
for (int currentErodeRecursion = 0; currentErodeRecursion < this.erodeRecursion; currentErodeRecursion++) for (int currentErodeRecursion = 0; currentErodeRecursion < this.erodeRecursion; currentErodeRecursion++) {
{
this.getMatrix(); this.getMatrix();
for (int z = 1; z < this.snap.length - 1; z++) for (int z = 1; z < this.snap.length - 1; z++) {
{
final double zSquared = Math.pow(z - (this.bsize + 1), 2); final double zSquared = Math.pow(z - (this.bsize + 1), 2);
for (int x = 1; x < this.snap.length - 1; x++) for (int x = 1; x < this.snap.length - 1; x++) {
{
final double xSquared = Math.pow(x - (this.bsize + 1), 2); final double xSquared = Math.pow(x - (this.bsize + 1), 2);
for (int y = 1; y < this.snap.length - 1; y++) for (int y = 1; y < this.snap.length - 1; y++) {
{
if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= bSquared)) if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= bSquared)) {
{ if (this.erode(x, y, z)) {
if (this.erode(x, y, z))
{
this.snap[x][y][z].getNativeBlock().setTypeId(BlockTypes.AIR.getInternalId()); this.snap[x][y][z].getNativeBlock().setTypeId(BlockTypes.AIR.getInternalId());
} }
} }
@ -321,14 +254,10 @@ public class RandomErodeBrush extends Brush
} }
} }
for (BlockWrapper[][] firstSnapSlice : this.firstSnap) for (BlockWrapper[][] firstSnapSlice : this.firstSnap) {
{ for (BlockWrapper[] firstSnapString : firstSnapSlice) {
for (BlockWrapper[] firstSnapString : firstSnapSlice) for (final BlockWrapper block : firstSnapString) {
{ if (block.getI() != block.getNativeBlock().getTypeId()) {
for (final BlockWrapper block : firstSnapString)
{
if (block.getI() != block.getNativeBlock().getTypeId())
{
undo.put(block.getNativeBlock()); undo.put(block.getNativeBlock());
} }
} }
@ -339,8 +268,7 @@ public class RandomErodeBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.bsize = v.getBrushSize(); this.bsize = v.getBrushSize();
this.snap = new BlockWrapper[0][0][0]; this.snap = new BlockWrapper[0][0][0];
@ -350,8 +278,7 @@ public class RandomErodeBrush extends Brush
this.erodeRecursion = this.generator.nextInt(3); this.erodeRecursion = this.generator.nextInt(3);
this.fillRecursion = this.generator.nextInt(3); this.fillRecursion = this.generator.nextInt(3);
if (this.fillRecursion == 0 && this.erodeRecursion == 0) if (this.fillRecursion == 0 && this.erodeRecursion == 0) { // if they are both zero, it will lead to a null pointer exception. Still want to give them a
{ // if they are both zero, it will lead to a null pointer exception. Still want to give them a
// chance to be zero though, for more interestingness -Gav // chance to be zero though, for more interestingness -Gav
this.erodeRecursion = this.generator.nextInt(2) + 1; this.erodeRecursion = this.generator.nextInt(2) + 1;
this.fillRecursion = this.generator.nextInt(2) + 1; this.fillRecursion = this.generator.nextInt(2) + 1;
@ -361,8 +288,7 @@ public class RandomErodeBrush extends Brush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.bsize = v.getBrushSize(); this.bsize = v.getBrushSize();
this.snap = new BlockWrapper[0][0][0]; this.snap = new BlockWrapper[0][0][0];
@ -371,8 +297,7 @@ public class RandomErodeBrush extends Brush
this.fillFace = this.generator.nextInt(5) + 1; this.fillFace = this.generator.nextInt(5) + 1;
this.erodeRecursion = this.generator.nextInt(3); this.erodeRecursion = this.generator.nextInt(3);
this.fillRecursion = this.generator.nextInt(3); this.fillRecursion = this.generator.nextInt(3);
if (this.fillRecursion == 0 && this.erodeRecursion == 0) if (this.fillRecursion == 0 && this.erodeRecursion == 0) { // if they are both zero, it will lead to a null pointer exception. Still want to give them a
{ // if they are both zero, it will lead to a null pointer exception. Still want to give them a
// chance to be zero though, for more interestingness -Gav // chance to be zero though, for more interestingness -Gav
this.erodeRecursion = this.generator.nextInt(2) + 1; this.erodeRecursion = this.generator.nextInt(2) + 1;
this.fillRecursion = this.generator.nextInt(2) + 1; this.fillRecursion = this.generator.nextInt(2) + 1;
@ -382,17 +307,20 @@ public class RandomErodeBrush extends Brush
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override
public String getPermissionNode() {
return "voxelsniper.brush.randomerode";
}
/** /**
* @author unknown * @author unknown
*/ */
private class BlockWrapper private class BlockWrapper {
{
private boolean solid; private boolean solid;
private AsyncBlock nativeBlock; private AsyncBlock nativeBlock;
private int id; private int id;
@ -402,12 +330,10 @@ public class RandomErodeBrush extends Brush
* @param bl * @param bl
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public BlockWrapper(final AsyncBlock bl) public BlockWrapper(final AsyncBlock bl) {
{
this.setNativeBlock(bl); this.setNativeBlock(bl);
this.setI(bl.getTypeId()); this.setI(bl.getTypeId());
switch (bl.getType()) switch (bl.getType()) {
{
case AIR: case AIR:
this.setSolid(false); this.setSolid(false);
break; break;
@ -422,50 +348,36 @@ public class RandomErodeBrush extends Brush
} }
} }
public boolean isSolid() public boolean isSolid() {
{
return solid; return solid;
} }
public void setSolid(boolean solid) public void setSolid(boolean solid) {
{
this.solid = solid; this.solid = solid;
} }
public AsyncBlock getNativeBlock() public AsyncBlock getNativeBlock() {
{
return nativeBlock; return nativeBlock;
} }
public void setNativeBlock(AsyncBlock nativeBlock) public void setNativeBlock(AsyncBlock nativeBlock) {
{
this.nativeBlock = nativeBlock; this.nativeBlock = nativeBlock;
} }
public int getId() public int getId() {
{
return id; return id;
} }
public void setId(int id) public void setId(int id) {
{
this.id = id; this.id = id;
} }
public int getI() public int getI() {
{
return i; return i;
} }
public void setI(int i) public void setI(int i) {
{
this.i = i; this.i = i;
} }
} }
@Override
public String getPermissionNode()
{
return "voxelsniper.brush.randomerode";
}
} }

Datei anzeigen

@ -10,27 +10,21 @@ import org.bukkit.Chunk;
* *
* @author Mick * @author Mick
*/ */
public class RegenerateChunkBrush extends Brush public class RegenerateChunkBrush extends Brush {
{
/** /**
* *
*/ */
public RegenerateChunkBrush() public RegenerateChunkBrush() {
{
this.setName("Chunk Generator 40k"); this.setName("Chunk Generator 40k");
} }
private void generateChunk(final SnipeData v) private void generateChunk(final SnipeData v) {
{
final Chunk chunk = this.getTargetBlock().getChunk(); final Chunk chunk = this.getTargetBlock().getChunk();
final Undo undo = new Undo(); final Undo undo = new Undo();
for (int z = CHUNK_SIZE; z >= 0; z--) for (int z = CHUNK_SIZE; z >= 0; z--) {
{ for (int x = CHUNK_SIZE; x >= 0; x--) {
for (int x = CHUNK_SIZE; x >= 0; x--) for (int y = this.getWorld().getMaxHeight(); y >= 0; y--) {
{
for (int y = this.getWorld().getMaxHeight(); y >= 0; y--)
{
undo.put(chunk.getBlock(x, y, z)); undo.put(chunk.getBlock(x, y, z));
} }
} }
@ -43,28 +37,24 @@ public class RegenerateChunkBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.generateChunk(v); this.generateChunk(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.generateChunk(v); this.generateChunk(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.brushMessage("Tread lightly."); vm.brushMessage("Tread lightly.");
vm.brushMessage("This brush will melt your spleen and sell your kidneys."); vm.brushMessage("This brush will melt your spleen and sell your kidneys.");
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.regeneratechunk"; return "voxelsniper.brush.regeneratechunk";
} }
} }

Datei anzeigen

@ -5,40 +5,33 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Ring_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#Ring_Brush
* *
* @author Voxel * @author Voxel
*/ */
public class RingBrush extends PerformBrush public class RingBrush extends PerformBrush {
{
private double trueCircle = 0; private double trueCircle = 0;
private double innerSize = 0; private double innerSize = 0;
/** /**
* *
*/ */
public RingBrush() public RingBrush() {
{
this.setName("Ring"); this.setName("Ring");
} }
private void ring(final SnipeData v, AsyncBlock targetBlock) private void ring(final SnipeData v, AsyncBlock targetBlock) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final double outerSquared = Math.pow(brushSize + this.trueCircle, 2); final double outerSquared = Math.pow(brushSize + this.trueCircle, 2);
final double innerSquared = Math.pow(this.innerSize, 2); final double innerSquared = Math.pow(this.innerSize, 2);
for (int x = brushSize; x >= 0; x--) for (int x = brushSize; x >= 0; x--) {
{
final double xSquared = Math.pow(x, 2); final double xSquared = Math.pow(x, 2);
for (int z = brushSize; z >= 0; z--) for (int z = brushSize; z >= 0; z--) {
{
final double ySquared = Math.pow(z, 2); final double ySquared = Math.pow(z, 2);
if ((xSquared + ySquared) <= outerSquared && (xSquared + ySquared) >= innerSquared) if ((xSquared + ySquared) <= outerSquared && (xSquared + ySquared) >= innerSquared) {
{
current.perform(targetBlock.getRelative(x, 0, z)); current.perform(targetBlock.getRelative(x, 0, z));
current.perform(targetBlock.getRelative(x, 0, -z)); current.perform(targetBlock.getRelative(x, 0, -z));
current.perform(targetBlock.getRelative(-x, 0, z)); current.perform(targetBlock.getRelative(-x, 0, z));
@ -51,70 +44,52 @@ public class RingBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.ring(v, this.getTargetBlock()); this.ring(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.ring(v, this.getLastBlock()); this.ring(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.custom(ChatColor.AQUA + "The inner radius is " + ChatColor.RED + this.innerSize); vm.custom(ChatColor.AQUA + "The inner radius is " + ChatColor.RED + this.innerSize);
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++) if (par[i].equalsIgnoreCase("info")) {
{
if (par[i].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Ring Brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Ring Brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b ri true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b ri false will switch back. (false is default)"); v.sendMessage(ChatColor.AQUA + "/b ri true -- will use a true circle algorithm instead of the skinnier version with classic sniper nubs. /b ri false will switch back. (false is default)");
v.sendMessage(ChatColor.AQUA + "/b ri ir2.5 -- will set the inner radius to 2.5 units"); v.sendMessage(ChatColor.AQUA + "/b ri ir2.5 -- will set the inner radius to 2.5 units");
return; return;
} } else if (par[i].startsWith("true")) {
else if (par[i].startsWith("true"))
{
this.trueCircle = 0.5; this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON."); v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
} } else if (par[i].startsWith("false")) {
else if (par[i].startsWith("false"))
{
this.trueCircle = 0; this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} } else if (par[i].startsWith("ir")) {
else if (par[i].startsWith("ir")) try {
{
try
{
final double d = Double.parseDouble(par[i].replace("ir", "")); final double d = Double.parseDouble(par[i].replace("ir", ""));
this.innerSize = d; this.innerSize = d;
v.sendMessage(ChatColor.AQUA + "The inner radius has been set to " + ChatColor.RED + this.innerSize); v.sendMessage(ChatColor.AQUA + "The inner radius has been set to " + ChatColor.RED + this.innerSize);
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "The parameters included are invalid."); v.sendMessage(ChatColor.RED + "The parameters included are invalid.");
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.ring"; return "voxelsniper.brush.ring";
} }
} }

Datei anzeigen

@ -5,14 +5,12 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.util.BlockWrapper; import com.thevoxelbox.voxelsniper.util.BlockWrapper;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
/** /**
* @author Piotr * @author Piotr
*/ */
public class Rot2DBrush extends Brush public class Rot2DBrush extends Brush {
{
private int mode = 0; private int mode = 0;
private int bSize; private int bSize;
private int brushSize; private int brushSize;
@ -22,14 +20,12 @@ public class Rot2DBrush extends Brush
/** /**
* *
*/ */
public Rot2DBrush() public Rot2DBrush() {
{
this.setName("2D Rotation"); this.setName("2D Rotation");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void getMatrix() private void getMatrix() {
{
this.brushSize = (this.bSize * 2) + 1; this.brushSize = (this.bSize * 2) + 1;
this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize]; this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize];
@ -39,17 +35,13 @@ public class Rot2DBrush extends Brush
int sy = this.getTargetBlock().getY() - this.bSize; int sy = this.getTargetBlock().getY() - this.bSize;
int sz = this.getTargetBlock().getZ() - this.bSize; int sz = this.getTargetBlock().getZ() - this.bSize;
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
sz = this.getTargetBlock().getZ() - this.bSize; sz = this.getTargetBlock().getZ() - this.bSize;
final double xSquared = Math.pow(x - this.bSize, 2); final double xSquared = Math.pow(x - this.bSize, 2);
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{
sy = this.getTargetBlock().getY() - this.bSize; sy = this.getTargetBlock().getY() - this.bSize;
if (xSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) if (xSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) {
{ for (int z = 0; z < this.snap.length; z++) {
for (int z = 0; z < this.snap.length; z++)
{
final AsyncBlock block = this.clampY(sx, sy, sz); // why is this not sx + x, sy + y sz + z? final AsyncBlock block = this.clampY(sx, sy, sz); // why is this not sx + x, sy + y sz + z?
this.snap[x][z][y] = new BlockWrapper(block); this.snap[x][z][y] = new BlockWrapper(block);
block.setTypeId(BlockTypes.AIR.getInternalId()); block.setTypeId(BlockTypes.AIR.getInternalId());
@ -62,8 +54,7 @@ public class Rot2DBrush extends Brush
} }
} }
private void rotate(final SnipeData v) private void rotate(final SnipeData v) {
{
final double brushSiyeSquared = Math.pow(this.bSize + 0.5, 2); final double brushSiyeSquared = Math.pow(this.bSize + 0.5, 2);
final double cos = Math.cos(this.se); final double cos = Math.cos(this.se);
final double sin = Math.sin(this.se); final double sin = Math.sin(this.se);
@ -72,29 +63,24 @@ public class Rot2DBrush extends Brush
// Also, new array keeps track of which x and z coords are being assigned in the rotated space so that we can // Also, new array keeps track of which x and z coords are being assigned in the rotated space so that we can
// do a targeted filling of only those columns later that were left out. // do a targeted filling of only those columns later that were left out.
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
final int xx = x - this.bSize; final int xx = x - this.bSize;
final double xSquared = Math.pow(xx, 2); final double xSquared = Math.pow(xx, 2);
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{
final int zz = y - this.bSize; final int zz = y - this.bSize;
if (xSquared + Math.pow(zz, 2) <= brushSiyeSquared) if (xSquared + Math.pow(zz, 2) <= brushSiyeSquared) {
{
final double newX = (xx * cos) - (zz * sin); final double newX = (xx * cos) - (zz * sin);
final double newZ = (xx * sin) + (zz * cos); final double newZ = (xx * sin) + (zz * cos);
doNotFill[(int) newX + this.bSize][(int) newZ + this.bSize] = true; doNotFill[(int) newX + this.bSize][(int) newZ + this.bSize] = true;
for (int currentY = 0; currentY < this.snap.length; currentY++) for (int currentY = 0; currentY < this.snap.length; currentY++) {
{
final int yy = currentY - this.bSize; final int yy = currentY - this.bSize;
final BlockWrapper block = this.snap[x][currentY][y]; final BlockWrapper block = this.snap[x][currentY][y];
if (BlockTypes.get(block.getId()).getMaterial().isAir()) if (BlockTypes.get(block.getId()).getMaterial().isAir()) {
{
continue; continue;
} }
this.setBlockIdAndDataAt(this.getTargetBlock().getX() + (int) newX, this.getTargetBlock().getY() + yy, this.getTargetBlock().getZ() + (int) newZ, block.getId(), block.getPropertyId()); this.setBlockIdAndDataAt(this.getTargetBlock().getX() + (int) newX, this.getTargetBlock().getY() + yy, this.getTargetBlock().getZ() + (int) newZ, block.getId(), block.getPropertyId());
@ -102,23 +88,18 @@ public class Rot2DBrush extends Brush
} }
} }
} }
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
final double xSquared = Math.pow(x - this.bSize, 2); final double xSquared = Math.pow(x - this.bSize, 2);
final int fx = x + this.getTargetBlock().getX() - this.bSize; final int fx = x + this.getTargetBlock().getX() - this.bSize;
for (int z = 0; z < this.snap.length; z++) for (int z = 0; z < this.snap.length; z++) {
{ if (xSquared + Math.pow(z - this.bSize, 2) <= brushSiyeSquared) {
if (xSquared + Math.pow(z - this.bSize, 2) <= brushSiyeSquared)
{
final int fz = z + this.getTargetBlock().getZ() - this.bSize; final int fz = z + this.getTargetBlock().getZ() - this.bSize;
if (!doNotFill[x][z]) if (!doNotFill[x][z]) {
{
// smart fill stuff // smart fill stuff
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{
final int fy = y + this.getTargetBlock().getY() - this.bSize; final int fy = y + this.getTargetBlock().getY() - this.bSize;
final int a = this.getBlockIdAt(fx + 1, fy, fz); final int a = this.getBlockIdAt(fx + 1, fy, fz);
@ -132,20 +113,15 @@ public class Rot2DBrush extends Brush
int winner; int winner;
int winnerData; int winnerData;
if (a == b || a == c || a == d) if (a == b || a == c || a == d) { // I figure that since we are already narrowing it down to ONLY the holes left behind, it
{ // I figure that since we are already narrowing it down to ONLY the holes left behind, it
// should // should
// be fine to do all 5 checks needed to be legit about it. // be fine to do all 5 checks needed to be legit about it.
winner = a; winner = a;
winnerData = aData; winnerData = aData;
} } else if (b == d || c == d) {
else if (b == d || c == d)
{
winner = d; winner = d;
winnerData = dData; winnerData = dData;
} } else {
else
{
winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C; winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C;
winnerData = bData; winnerData = bData;
} }
@ -159,8 +135,7 @@ public class Rot2DBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.bSize = v.getBrushSize(); this.bSize = v.getBrushSize();
if (this.mode == 0) { if (this.mode == 0) {
@ -172,8 +147,7 @@ public class Rot2DBrush extends Brush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.bSize = v.getBrushSize(); this.bSize = v.getBrushSize();
if (this.mode == 0) { if (this.mode == 0) {
@ -185,21 +159,18 @@ public class Rot2DBrush extends Brush
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{
this.se = Math.toRadians(Double.parseDouble(par[1])); this.se = Math.toRadians(Double.parseDouble(par[1]));
v.sendMessage(ChatColor.GREEN + "Angle set to " + this.se); v.sendMessage(ChatColor.GREEN + "Angle set to " + this.se);
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.rot2d"; return "voxelsniper.brush.rot2d";
} }
} }

Datei anzeigen

@ -5,7 +5,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.util.BlockWrapper; import com.thevoxelbox.voxelsniper.util.BlockWrapper;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -14,8 +13,7 @@ import org.bukkit.ChatColor;
*/ */
// The X Y and Z variable names in this file do NOT MAKE ANY SENSE. Do not attempt to actually figure out what on earth is going on here. Just go to the // The X Y and Z variable names in this file do NOT MAKE ANY SENSE. Do not attempt to actually figure out what on earth is going on here. Just go to the
// original 2d horizontal brush if you wish to make anything similar to this, and start there. I didn't bother renaming everything. // original 2d horizontal brush if you wish to make anything similar to this, and start there. I didn't bother renaming everything.
public class Rot2DvertBrush extends Brush public class Rot2DvertBrush extends Brush {
{
private int mode = 0; private int mode = 0;
private int bSize; private int bSize;
private int brushSize; private int brushSize;
@ -25,14 +23,12 @@ public class Rot2DvertBrush extends Brush
/** /**
* *
*/ */
public Rot2DvertBrush() public Rot2DvertBrush() {
{
this.setName("2D Rotation"); this.setName("2D Rotation");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void getMatrix() private void getMatrix() {
{
this.brushSize = (this.bSize * 2) + 1; this.brushSize = (this.bSize * 2) + 1;
this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize]; this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize];
@ -41,16 +37,13 @@ public class Rot2DvertBrush extends Brush
int sy = this.getTargetBlock().getY() - this.bSize; int sy = this.getTargetBlock().getY() - this.bSize;
int sz = this.getTargetBlock().getZ() - this.bSize; int sz = this.getTargetBlock().getZ() - this.bSize;
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
sz = this.getTargetBlock().getZ() - this.bSize; sz = this.getTargetBlock().getZ() - this.bSize;
for (int z = 0; z < this.snap.length; z++) for (int z = 0; z < this.snap.length; z++) {
{
sy = this.getTargetBlock().getY() - this.bSize; sy = this.getTargetBlock().getY() - this.bSize;
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{
final AsyncBlock block = this.clampY(sx, sy, sz); // why is this not sx + x, sy + y sz + z? final AsyncBlock block = this.clampY(sx, sy, sz); // why is this not sx + x, sy + y sz + z?
this.snap[x][y][z] = new BlockWrapper(block); this.snap[x][y][z] = new BlockWrapper(block);
block.setTypeId(BlockTypes.AIR.getInternalId()); block.setTypeId(BlockTypes.AIR.getInternalId());
@ -63,8 +56,7 @@ public class Rot2DvertBrush extends Brush
} }
} }
private void rotate(final SnipeData v) private void rotate(final SnipeData v) {
{
final double brushSizeSquared = Math.pow(this.bSize + 0.5, 2); final double brushSizeSquared = Math.pow(this.bSize + 0.5, 2);
final double cos = Math.cos(this.se); final double cos = Math.cos(this.se);
final double sin = Math.sin(this.se); final double sin = Math.sin(this.se);
@ -73,29 +65,24 @@ public class Rot2DvertBrush extends Brush
// Also, new array keeps track of which x and z coords are being assigned in the rotated space so that we can // Also, new array keeps track of which x and z coords are being assigned in the rotated space so that we can
// do a targeted filling of only those columns later that were left out. // do a targeted filling of only those columns later that were left out.
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
final int xx = x - this.bSize; final int xx = x - this.bSize;
final double xSquared = Math.pow(xx, 2); final double xSquared = Math.pow(xx, 2);
for (int z = 0; z < this.snap.length; z++) for (int z = 0; z < this.snap.length; z++) {
{
final int zz = z - this.bSize; final int zz = z - this.bSize;
if (xSquared + Math.pow(zz, 2) <= brushSizeSquared) if (xSquared + Math.pow(zz, 2) <= brushSizeSquared) {
{
final double newX = (xx * cos) - (zz * sin); final double newX = (xx * cos) - (zz * sin);
final double newZ = (xx * sin) + (zz * cos); final double newZ = (xx * sin) + (zz * cos);
doNotFill[(int) newX + this.bSize][(int) newZ + this.bSize] = true; doNotFill[(int) newX + this.bSize][(int) newZ + this.bSize] = true;
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{
final int yy = y - this.bSize; final int yy = y - this.bSize;
final BlockWrapper block = this.snap[y][x][z]; final BlockWrapper block = this.snap[y][x][z];
if (BlockTypes.get(block.getId()).getMaterial().isAir()) if (BlockTypes.get(block.getId()).getMaterial().isAir()) {
{
continue; continue;
} }
this.setBlockIdAndDataAt(this.getTargetBlock().getX() + yy, this.getTargetBlock().getY() + (int) newX, this.getTargetBlock().getZ() + (int) newZ, block.getId(), block.getPropertyId()); this.setBlockIdAndDataAt(this.getTargetBlock().getX() + yy, this.getTargetBlock().getY() + (int) newX, this.getTargetBlock().getZ() + (int) newZ, block.getId(), block.getPropertyId());
@ -104,22 +91,17 @@ public class Rot2DvertBrush extends Brush
} }
} }
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
final double xSquared = Math.pow(x - this.bSize, 2); final double xSquared = Math.pow(x - this.bSize, 2);
final int fx = x + this.getTargetBlock().getX() - this.bSize; final int fx = x + this.getTargetBlock().getX() - this.bSize;
for (int z = 0; z < this.snap.length; z++) for (int z = 0; z < this.snap.length; z++) {
{ if (xSquared + Math.pow(z - this.bSize, 2) <= brushSizeSquared) {
if (xSquared + Math.pow(z - this.bSize, 2) <= brushSizeSquared)
{
final int fz = z + this.getTargetBlock().getZ() - this.bSize; final int fz = z + this.getTargetBlock().getZ() - this.bSize;
if (!doNotFill[x][z]) if (!doNotFill[x][z]) {
{
// smart fill stuff // smart fill stuff
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{
final int fy = y + this.getTargetBlock().getY() - this.bSize; final int fy = y + this.getTargetBlock().getY() - this.bSize;
final int a = this.getBlockIdAt(fy, fx + 1, fz); final int a = this.getBlockIdAt(fy, fx + 1, fz);
@ -133,20 +115,15 @@ public class Rot2DvertBrush extends Brush
int winner; int winner;
int winnerData; int winnerData;
if (a == b || a == c || a == d) if (a == b || a == c || a == d) { // I figure that since we are already narrowing it down to ONLY the holes left behind, it
{ // I figure that since we are already narrowing it down to ONLY the holes left behind, it
// should // should
// be fine to do all 5 checks needed to be legit about it. // be fine to do all 5 checks needed to be legit about it.
winner = a; winner = a;
winnerData = aData; winnerData = aData;
} } else if (b == d || c == d) {
else if (b == d || c == d)
{
winner = d; winner = d;
winnerData = dData; winnerData = dData;
} } else {
else
{
winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C; winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C;
winnerData = bData; winnerData = bData;
} }
@ -160,8 +137,7 @@ public class Rot2DvertBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.bSize = v.getBrushSize(); this.bSize = v.getBrushSize();
if (this.mode == 0) { if (this.mode == 0) {
@ -173,8 +149,7 @@ public class Rot2DvertBrush extends Brush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.bSize = v.getBrushSize(); this.bSize = v.getBrushSize();
if (this.mode == 0) { if (this.mode == 0) {
@ -186,29 +161,23 @@ public class Rot2DvertBrush extends Brush
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ try {
try
{
this.se = Math.toRadians(Double.parseDouble(par[1])); this.se = Math.toRadians(Double.parseDouble(par[1]));
v.sendMessage(ChatColor.GREEN + "Angle set to " + this.se); v.sendMessage(ChatColor.GREEN + "Angle set to " + this.se);
} } catch (Exception _ex) {
catch (Exception _ex)
{
v.sendMessage("Exception while parsing parameter: " + par[1]); v.sendMessage("Exception while parsing parameter: " + par[1]);
Bukkit.getLogger().severe(_ex.getMessage()); Bukkit.getLogger().severe(_ex.getMessage());
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.rot2dvert"; return "voxelsniper.brush.rot2dvert";
} }
} }

Datei anzeigen

@ -6,14 +6,12 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import com.thevoxelbox.voxelsniper.util.BlockWrapper; import com.thevoxelbox.voxelsniper.util.BlockWrapper;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
/** /**
* *
*/ */
public class Rot3DBrush extends Brush public class Rot3DBrush extends Brush {
{
private final int mode = 0; private final int mode = 0;
private int bSize; private int bSize;
private int brushSize; private int brushSize;
@ -25,14 +23,12 @@ public class Rot3DBrush extends Brush
/** /**
* *
*/ */
public Rot3DBrush() public Rot3DBrush() {
{
this.setName("3D Rotation"); this.setName("3D Rotation");
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.brushMessage("Rotates Yaw (XZ), then Pitch(XY), then Roll(ZY), in order."); vm.brushMessage("Rotates Yaw (XZ), then Pitch(XY), then Roll(ZY), in order.");
} }
@ -42,45 +38,33 @@ public class Rot3DBrush extends Brush
// matrix and compare Block.getId with 'id' if different undo.add( new BlockWrapper ( Block, oldId ) ) // matrix and compare Block.getId with 'id' if different undo.add( new BlockWrapper ( Block, oldId ) )
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
// which way is clockwise is less obvious for roll and pitch... should probably fix that / make it clear // which way is clockwise is less obvious for roll and pitch... should probably fix that / make it clear
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Rotate brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Rotate brush Parameters:");
v.sendMessage(ChatColor.AQUA + "p[0-359] -- set degrees of pitch rotation (rotation about the Z axis)."); v.sendMessage(ChatColor.AQUA + "p[0-359] -- set degrees of pitch rotation (rotation about the Z axis).");
v.sendMessage(ChatColor.BLUE + "r[0-359] -- set degrees of roll rotation (rotation about the X axis)."); v.sendMessage(ChatColor.BLUE + "r[0-359] -- set degrees of roll rotation (rotation about the X axis).");
v.sendMessage(ChatColor.LIGHT_PURPLE + "y[0-359] -- set degrees of yaw rotation (Rotation about the Y axis)."); v.sendMessage(ChatColor.LIGHT_PURPLE + "y[0-359] -- set degrees of yaw rotation (Rotation about the Y axis).");
return; return;
} } else if (parameter.startsWith("p")) {
else if (parameter.startsWith("p"))
{
this.sePitch = Math.toRadians(Double.parseDouble(parameter.replace("p", ""))); this.sePitch = Math.toRadians(Double.parseDouble(parameter.replace("p", "")));
v.sendMessage(ChatColor.AQUA + "Around Z-axis degrees set to " + this.sePitch); v.sendMessage(ChatColor.AQUA + "Around Z-axis degrees set to " + this.sePitch);
if (this.sePitch < 0 || this.sePitch > 359) if (this.sePitch < 0 || this.sePitch > 359) {
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! Angles must be from 1-359"); v.sendMessage(ChatColor.RED + "Invalid brush parameters! Angles must be from 1-359");
} }
} } else if (parameter.startsWith("r")) {
else if (parameter.startsWith("r"))
{
this.seRoll = Math.toRadians(Double.parseDouble(parameter.replace("r", ""))); this.seRoll = Math.toRadians(Double.parseDouble(parameter.replace("r", "")));
v.sendMessage(ChatColor.AQUA + "Around X-axis degrees set to " + this.seRoll); v.sendMessage(ChatColor.AQUA + "Around X-axis degrees set to " + this.seRoll);
if (this.seRoll < 0 || this.seRoll > 359) if (this.seRoll < 0 || this.seRoll > 359) {
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! Angles must be from 1-359"); v.sendMessage(ChatColor.RED + "Invalid brush parameters! Angles must be from 1-359");
} }
} } else if (parameter.startsWith("y")) {
else if (parameter.startsWith("y"))
{
this.seYaw = Math.toRadians(Double.parseDouble(parameter.replace("y", ""))); this.seYaw = Math.toRadians(Double.parseDouble(parameter.replace("y", "")));
v.sendMessage(ChatColor.AQUA + "Around Y-axis degrees set to " + this.seYaw); v.sendMessage(ChatColor.AQUA + "Around Y-axis degrees set to " + this.seYaw);
if (this.seYaw < 0 || this.seYaw > 359) if (this.seYaw < 0 || this.seYaw > 359) {
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! Angles must be from 1-359"); v.sendMessage(ChatColor.RED + "Invalid brush parameters! Angles must be from 1-359");
} }
} }
@ -88,8 +72,7 @@ public class Rot3DBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void getMatrix() private void getMatrix() { // only need to do once. But y needs to change + sphere
{ // only need to do once. But y needs to change + sphere
final double brushSizeSquared = Math.pow(this.bSize + 0.5, 2); final double brushSizeSquared = Math.pow(this.bSize + 0.5, 2);
this.brushSize = (this.bSize * 2) + 1; this.brushSize = (this.bSize * 2) + 1;
@ -99,20 +82,16 @@ public class Rot3DBrush extends Brush
//int sy = this.getTargetBlock().getY() - this.bSize; Not used //int sy = this.getTargetBlock().getY() - this.bSize; Not used
int sz = this.getTargetBlock().getZ() - this.bSize; int sz = this.getTargetBlock().getZ() - this.bSize;
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
final double xSquared = Math.pow(x - this.bSize, 2); final double xSquared = Math.pow(x - this.bSize, 2);
sz = this.getTargetBlock().getZ() - this.bSize; sz = this.getTargetBlock().getZ() - this.bSize;
for (int z = 0; z < this.snap.length; z++) for (int z = 0; z < this.snap.length; z++) {
{
final double zSquared = Math.pow(z - this.bSize, 2); final double zSquared = Math.pow(z - this.bSize, 2);
sz = this.getTargetBlock().getY() - this.bSize; sz = this.getTargetBlock().getY() - this.bSize;
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{ if (xSquared + zSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) {
if (xSquared + zSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared)
{
final AsyncBlock block = this.clampY(sx, sz, sz); final AsyncBlock block = this.clampY(sx, sz, sz);
this.snap[x][y][z] = new BlockWrapper(block); this.snap[x][y][z] = new BlockWrapper(block);
block.setTypeId(BlockTypes.AIR.getInternalId()); block.setTypeId(BlockTypes.AIR.getInternalId());
@ -127,8 +106,7 @@ public class Rot3DBrush extends Brush
} }
private void rotate(final SnipeData v) private void rotate(final SnipeData v) {
{
// basically 1) make it a sphere we are rotating in, not a cylinder // basically 1) make it a sphere we are rotating in, not a cylinder
// 2) do three rotations in a row, one in each dimension, unless some dimensions are set to zero or udnefined or whatever, then skip those. // 2) do three rotations in a row, one in each dimension, unless some dimensions are set to zero or udnefined or whatever, then skip those.
// --> Why not utilize Sniper'world new oportunities and have arrow rotate all 3, powder rotate x, goldsisc y, otherdisc z. Or something like that. Or // --> Why not utilize Sniper'world new oportunities and have arrow rotate all 3, powder rotate x, goldsisc y, otherdisc z. Or something like that. Or
@ -147,23 +125,19 @@ public class Rot3DBrush extends Brush
final boolean[][][] doNotFill = new boolean[this.snap.length][this.snap.length][this.snap.length]; final boolean[][][] doNotFill = new boolean[this.snap.length][this.snap.length][this.snap.length];
final Undo undo = new Undo(); final Undo undo = new Undo();
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
final int xx = x - this.bSize; final int xx = x - this.bSize;
final double xSquared = Math.pow(xx, 2); final double xSquared = Math.pow(xx, 2);
for (int z = 0; z < this.snap.length; z++) for (int z = 0; z < this.snap.length; z++) {
{
final int zz = z - this.bSize; final int zz = z - this.bSize;
final double zSquared = Math.pow(zz, 2); final double zSquared = Math.pow(zz, 2);
final double newxzX = (xx * cosYaw) - (zz * sinYaw); final double newxzX = (xx * cosYaw) - (zz * sinYaw);
final double newxzZ = (xx * sinYaw) + (zz * cosYaw); final double newxzZ = (xx * sinYaw) + (zz * cosYaw);
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{
final int yy = y - this.bSize; final int yy = y - this.bSize;
if (xSquared + zSquared + Math.pow(yy, 2) <= brushSizeSquared) if (xSquared + zSquared + Math.pow(yy, 2) <= brushSizeSquared) {
{
undo.put(this.clampY(this.getTargetBlock().getX() + xx, this.getTargetBlock().getY() + yy, this.getTargetBlock().getZ() + zz)); // just store undo.put(this.clampY(this.getTargetBlock().getX() + xx, this.getTargetBlock().getY() + yy, this.getTargetBlock().getZ() + zz)); // just store
// whole sphere in undo, too complicated otherwise, since this brush both adds and remos things unpredictably. // whole sphere in undo, too complicated otherwise, since this brush both adds and remos things unpredictably.
@ -177,8 +151,7 @@ public class Rot3DBrush extends Brush
// after all three, though. // after all three, though.
final BlockWrapper block = this.snap[x][y][z]; final BlockWrapper block = this.snap[x][y][z];
if (BlockTypes.get(block.getId()).getMaterial().isAir()) if (BlockTypes.get(block.getId()).getMaterial().isAir()) {
{
continue; continue;
} }
this.setBlockIdAndDataAt(this.getTargetBlock().getX() + (int) newxyX, this.getTargetBlock().getY() + (int) newyzY, this.getTargetBlock().getZ() + (int) newyzZ, block.getId(), block.getPropertyId()); this.setBlockIdAndDataAt(this.getTargetBlock().getX() + (int) newxyX, this.getTargetBlock().getY() + (int) newyzY, this.getTargetBlock().getZ() + (int) newyzZ, block.getId(), block.getPropertyId());
@ -187,22 +160,17 @@ public class Rot3DBrush extends Brush
} }
} }
for (int x = 0; x < this.snap.length; x++) for (int x = 0; x < this.snap.length; x++) {
{
final double xSquared = Math.pow(x - this.bSize, 2); final double xSquared = Math.pow(x - this.bSize, 2);
final int fx = x + this.getTargetBlock().getX() - this.bSize; final int fx = x + this.getTargetBlock().getX() - this.bSize;
for (int z = 0; z < this.snap.length; z++) for (int z = 0; z < this.snap.length; z++) {
{
final double zSquared = Math.pow(z - this.bSize, 2); final double zSquared = Math.pow(z - this.bSize, 2);
final int fz = z + this.getTargetBlock().getZ() - this.bSize; final int fz = z + this.getTargetBlock().getZ() - this.bSize;
for (int y = 0; y < this.snap.length; y++) for (int y = 0; y < this.snap.length; y++) {
{ if (xSquared + zSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) {
if (xSquared + zSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) if (!doNotFill[x][y][z]) {
{
if (!doNotFill[x][y][z])
{
// smart fill stuff // smart fill stuff
final int fy = y + this.getTargetBlock().getY() - this.bSize; final int fy = y + this.getTargetBlock().getY() - this.bSize;
final int a = this.getBlockIdAt(fx + 1, fy, fz); final int a = this.getBlockIdAt(fx + 1, fy, fz);
@ -216,20 +184,15 @@ public class Rot3DBrush extends Brush
int winner; int winner;
int winnerData; int winnerData;
if (a == b || a == c || a == d) if (a == b || a == c || a == d) { // I figure that since we are already narrowing it down to ONLY the holes left behind, it
{ // I figure that since we are already narrowing it down to ONLY the holes left behind, it
// should // should
// be fine to do all 5 checks needed to be legit about it. // be fine to do all 5 checks needed to be legit about it.
winner = a; winner = a;
winnerData = aData; winnerData = aData;
} } else if (b == d || c == d) {
else if (b == d || c == d)
{
winner = d; winner = d;
winnerData = dData; winnerData = dData;
} } else {
else
{
winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C; winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C;
winnerData = bData; winnerData = bData;
} }
@ -244,8 +207,7 @@ public class Rot3DBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.bSize = v.getBrushSize(); this.bSize = v.getBrushSize();
if (this.mode == 0) { if (this.mode == 0) {
@ -257,8 +219,7 @@ public class Rot3DBrush extends Brush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.bSize = v.getBrushSize(); this.bSize = v.getBrushSize();
if (this.mode == 0) { if (this.mode == 0) {
@ -270,8 +231,7 @@ public class Rot3DBrush extends Brush
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.rot3d"; return "voxelsniper.brush.rot3d";
} }
} }

Datei anzeigen

@ -3,7 +3,6 @@ package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -12,8 +11,7 @@ import org.bukkit.util.Vector;
* *
* @author Gavjenks * @author Gavjenks
*/ */
public class RulerBrush extends Brush public class RulerBrush extends Brush {
{
private boolean first = true; private boolean first = true;
private Vector coords = new Vector(0, 0, 0); private Vector coords = new Vector(0, 0, 0);
@ -24,24 +22,19 @@ public class RulerBrush extends Brush
/** /**
* *
*/ */
public RulerBrush() public RulerBrush() {
{
this.setName("Ruler"); this.setName("Ruler");
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
final int voxelMaterialId = v.getVoxelId(); final int voxelMaterialId = v.getVoxelId();
this.coords = this.getTargetBlock().getLocation().toVector(); this.coords = this.getTargetBlock().getLocation().toVector();
if (this.xOff == 0 && this.yOff == 0 && this.zOff == 0) if (this.xOff == 0 && this.yOff == 0 && this.zOff == 0) {
{
v.sendMessage(ChatColor.DARK_PURPLE + "First point selected."); v.sendMessage(ChatColor.DARK_PURPLE + "First point selected.");
this.first = !this.first; this.first = !this.first;
} } else {
else
{
final Undo undo = new Undo(); final Undo undo = new Undo();
undo.put(this.clampY(this.getTargetBlock().getX() + this.xOff, this.getTargetBlock().getY() + this.yOff, this.getTargetBlock().getZ() + this.zOff)); undo.put(this.clampY(this.getTargetBlock().getX() + this.xOff, this.getTargetBlock().getY() + this.yOff, this.getTargetBlock().getZ() + this.zOff));
@ -51,10 +44,8 @@ public class RulerBrush extends Brush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (this.coords == null || this.coords.lengthSquared() == 0) {
if (this.coords == null || this.coords.lengthSquared() == 0)
{
v.sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow. Comparing to point 0,0,0 instead."); v.sendMessage(ChatColor.RED + "Warning: You did not select a first coordinate with the arrow. Comparing to point 0,0,0 instead.");
return; return;
} }
@ -71,59 +62,44 @@ public class RulerBrush extends Brush
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.voxel(); vm.voxel();
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Ruler Brush instructions: Right click first point with the arrow. Right click with powder for distances from that block (can repeat without getting a new first block.) For placing blocks, use arrow and input the desired coordinates with parameters."); v.sendMessage(ChatColor.GOLD + "Ruler Brush instructions: Right click first point with the arrow. Right click with powder for distances from that block (can repeat without getting a new first block.) For placing blocks, use arrow and input the desired coordinates with parameters.");
v.sendMessage(ChatColor.LIGHT_PURPLE + "/b r x[x value] y[y value] z[z value] -- Will place blocks one at a time of the type you have set with /v at the location you click + this many units away. If you don't include a value, it will be zero. Don't include ANY values, and the brush will just measure distance."); v.sendMessage(ChatColor.LIGHT_PURPLE + "/b r x[x value] y[y value] z[z value] -- Will place blocks one at a time of the type you have set with /v at the location you click + this many units away. If you don't include a value, it will be zero. Don't include ANY values, and the brush will just measure distance.");
v.sendMessage(ChatColor.BLUE + "/b r ruler -- will reset the tool to just measure distances, not layout blocks."); v.sendMessage(ChatColor.BLUE + "/b r ruler -- will reset the tool to just measure distances, not layout blocks.");
return; return;
} } else if (parameter.startsWith("x")) {
else if (parameter.startsWith("x"))
{
this.xOff = Integer.parseInt(parameter.replace("x", "")); this.xOff = Integer.parseInt(parameter.replace("x", ""));
v.sendMessage(ChatColor.AQUA + "X offset set to " + this.xOff); v.sendMessage(ChatColor.AQUA + "X offset set to " + this.xOff);
} } else if (parameter.startsWith("y")) {
else if (parameter.startsWith("y"))
{
this.yOff = Integer.parseInt(parameter.replace("y", "")); this.yOff = Integer.parseInt(parameter.replace("y", ""));
v.sendMessage(ChatColor.AQUA + "Y offset set to " + this.yOff); v.sendMessage(ChatColor.AQUA + "Y offset set to " + this.yOff);
} } else if (parameter.startsWith("z")) {
else if (parameter.startsWith("z"))
{
this.zOff = Integer.parseInt(parameter.replace("z", "")); this.zOff = Integer.parseInt(parameter.replace("z", ""));
v.sendMessage(ChatColor.AQUA + "Z offset set to " + this.zOff); v.sendMessage(ChatColor.AQUA + "Z offset set to " + this.zOff);
} } else if (parameter.startsWith("ruler")) {
else if (parameter.startsWith("ruler"))
{
this.zOff = 0; this.zOff = 0;
this.yOff = 0; this.yOff = 0;
this.xOff = 0; this.xOff = 0;
v.sendMessage(ChatColor.BLUE + "Ruler mode."); v.sendMessage(ChatColor.BLUE + "Ruler mode.");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.ruler"; return "voxelsniper.brush.ruler";
} }
} }

Datei anzeigen

@ -4,7 +4,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -12,8 +11,7 @@ import org.bukkit.block.BlockFace;
/** /**
* @author DivineRage * @author DivineRage
*/ */
public class ScannerBrush extends Brush public class ScannerBrush extends Brush {
{
private static final int DEPTH_MIN = 1; private static final int DEPTH_MIN = 1;
private static final int DEPTH_DEFAULT = 24; private static final int DEPTH_DEFAULT = 24;
private static final int DEPTH_MAX = 64; private static final int DEPTH_MAX = 64;
@ -24,42 +22,30 @@ public class ScannerBrush extends Brush
/** /**
* *
*/ */
public ScannerBrush() public ScannerBrush() {
{
this.setName("Scanner"); this.setName("Scanner");
} }
private int clamp(final int value, final int min, final int max) private int clamp(final int value, final int min, final int max) {
{ if (value < min) {
if (value < min)
{
return min; return min;
} } else if (value > max) {
else if (value > max)
{
return max; return max;
} } else {
else
{
return value; return value;
} }
} }
private void scan(final SnipeData v, final BlockFace bf) private void scan(final SnipeData v, final BlockFace bf) {
{ if (bf == null) {
if (bf == null)
{
return; return;
} }
switch (bf) switch (bf) {
{
case NORTH: case NORTH:
// Scan south // Scan south
for (int i = 1; i < this.depth + 1; i++) for (int i = 1; i < this.depth + 1; i++) {
{ if (this.clampY(this.getTargetBlock().getX() + i, this.getTargetBlock().getY(), this.getTargetBlock().getZ()).getType() == this.checkFor) {
if (this.clampY(this.getTargetBlock().getX() + i, this.getTargetBlock().getY(), this.getTargetBlock().getZ()).getType() == this.checkFor)
{
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
return; return;
} }
@ -69,10 +55,8 @@ public class ScannerBrush extends Brush
case SOUTH: case SOUTH:
// Scan north // Scan north
for (int i = 1; i < this.depth + 1; i++) for (int i = 1; i < this.depth + 1; i++) {
{ if (this.clampY(this.getTargetBlock().getX() - i, this.getTargetBlock().getY(), this.getTargetBlock().getZ()).getType() == this.checkFor) {
if (this.clampY(this.getTargetBlock().getX() - i, this.getTargetBlock().getY(), this.getTargetBlock().getZ()).getType() == this.checkFor)
{
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
return; return;
} }
@ -82,10 +66,8 @@ public class ScannerBrush extends Brush
case EAST: case EAST:
// Scan west // Scan west
for (int i = 1; i < this.depth + 1; i++) for (int i = 1; i < this.depth + 1; i++) {
{ if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ() + i).getType() == this.checkFor) {
if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ() + i).getType() == this.checkFor)
{
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
return; return;
} }
@ -95,10 +77,8 @@ public class ScannerBrush extends Brush
case WEST: case WEST:
// Scan east // Scan east
for (int i = 1; i < this.depth + 1; i++) for (int i = 1; i < this.depth + 1; i++) {
{ if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ() - i).getType() == this.checkFor) {
if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ() - i).getType() == this.checkFor)
{
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
return; return;
} }
@ -108,14 +88,11 @@ public class ScannerBrush extends Brush
case UP: case UP:
// Scan down // Scan down
for (int i = 1; i < this.depth + 1; i++) for (int i = 1; i < this.depth + 1; i++) {
{ if ((this.getTargetBlock().getY() - i) <= 0) {
if ((this.getTargetBlock().getY() - i) <= 0)
{
break; break;
} }
if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() - i, this.getTargetBlock().getZ()).getType() == this.checkFor) if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() - i, this.getTargetBlock().getZ()).getType() == this.checkFor) {
{
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
return; return;
} }
@ -125,14 +102,11 @@ public class ScannerBrush extends Brush
case DOWN: case DOWN:
// Scan up // Scan up
for (int i = 1; i < this.depth + 1; i++) for (int i = 1; i < this.depth + 1; i++) {
{ if ((this.getTargetBlock().getY() + i) >= v.getWorld().getMaxHeight()) {
if ((this.getTargetBlock().getY() + i) >= v.getWorld().getMaxHeight())
{
break; break;
} }
if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() + i, this.getTargetBlock().getZ()).getType() == this.checkFor) if (this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY() + i, this.getTargetBlock().getZ()).getType() == this.checkFor) {
{
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks."); v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
return; return;
} }
@ -146,55 +120,45 @@ public class ScannerBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId())); this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId()));
this.scan(v, this.getTargetBlock().getFace(this.getLastBlock())); this.scan(v, this.getTargetBlock().getFace(this.getLastBlock()));
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId())); this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId()));
this.scan(v, this.getTargetBlock().getFace(this.getLastBlock())); this.scan(v, this.getTargetBlock().getFace(this.getLastBlock()));
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom(ChatColor.GREEN + "Scanner depth set to " + this.depth); vm.custom(ChatColor.GREEN + "Scanner depth set to " + this.depth);
vm.custom(ChatColor.GREEN + "Scanner scans for " + this.checkFor + " (change with /v #)"); vm.custom(ChatColor.GREEN + "Scanner scans for " + this.checkFor + " (change with /v #)");
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++) if (par[i].equalsIgnoreCase("info")) {
{
if (par[i].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Scanner brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Scanner brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b sc d# -- will set the search depth to #. Clamps to 1 - 64."); v.sendMessage(ChatColor.AQUA + "/b sc d# -- will set the search depth to #. Clamps to 1 - 64.");
return; return;
} }
if (par[i].startsWith("d")) if (par[i].startsWith("d")) {
{
this.depth = this.clamp(Integer.parseInt(par[i].substring(1)), DEPTH_MIN, DEPTH_MAX); this.depth = this.clamp(Integer.parseInt(par[i].substring(1)), DEPTH_MIN, DEPTH_MAX);
v.sendMessage(ChatColor.AQUA + "Scanner depth set to " + this.depth); v.sendMessage(ChatColor.AQUA + "Scanner depth set to " + this.depth);
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.scanner"; return "voxelsniper.brush.scanner";
} }
} }

Datei anzeigen

@ -11,30 +11,23 @@ import org.bukkit.block.Block;
* *
* @author Voxel * @author Voxel
*/ */
public class SetBrush extends PerformBrush public class SetBrush extends PerformBrush {
{
private static final int SELECTION_SIZE_MAX = 5000000; private static final int SELECTION_SIZE_MAX = 5000000;
private Block block = null; private Block block = null;
/** /**
* *
*/ */
public SetBrush() public SetBrush() {
{
this.setName("Set"); this.setName("Set");
} }
private boolean set(final Block bl, final SnipeData v) private boolean set(final Block bl, final SnipeData v) {
{ if (this.block == null) {
if (this.block == null)
{
this.block = bl; this.block = bl;
return true; return true;
} } else {
else if (!this.block.getWorld().getName().equals(bl.getWorld().getName())) {
{
if (!this.block.getWorld().getName().equals(bl.getWorld().getName()))
{
v.sendMessage(ChatColor.RED + "You selected points in different worlds!"); v.sendMessage(ChatColor.RED + "You selected points in different worlds!");
this.block = null; this.block = null;
return true; return true;
@ -46,18 +39,12 @@ public class SetBrush extends PerformBrush
final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY(); final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY();
final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ(); final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ();
if (Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY) > SELECTION_SIZE_MAX) if (Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY) > SELECTION_SIZE_MAX) {
{
v.sendMessage(ChatColor.RED + "Selection size above hardcoded limit, please use a smaller selection."); v.sendMessage(ChatColor.RED + "Selection size above hardcoded limit, please use a smaller selection.");
} } else {
else for (int y = lowY; y <= highY; y++) {
{ for (int x = lowX; x <= highX; x++) {
for (int y = lowY; y <= highY; y++) for (int z = lowZ; z <= highZ; z++) {
{
for (int x = lowX; x <= highX; x++)
{
for (int z = lowZ; z <= highZ; z++)
{
this.current.perform(this.clampY(x, y, z)); this.current.perform(this.clampY(x, y, z));
} }
} }
@ -70,47 +57,36 @@ public class SetBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ if (this.set(this.getTargetBlock(), v)) {
if (this.set(this.getTargetBlock(), v))
{
v.sendMessage(ChatColor.GRAY + "Point one"); v.sendMessage(ChatColor.GRAY + "Point one");
} } else {
else
{
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (this.set(this.getLastBlock(), v)) {
if (this.set(this.getLastBlock(), v))
{
v.sendMessage(ChatColor.GRAY + "Point one"); v.sendMessage(ChatColor.GRAY + "Point one");
} } else {
else
{
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
this.block = null; this.block = null;
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{
super.parameters(par, v); super.parameters(par, v);
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.set"; return "voxelsniper.brush.set";
} }
} }

Datei anzeigen

@ -11,8 +11,7 @@ import org.bukkit.block.Block;
/** /**
* @author Voxel * @author Voxel
*/ */
public class SetRedstoneFlipBrush extends Brush public class SetRedstoneFlipBrush extends Brush {
{
private Block block = null; private Block block = null;
private Undo undo; private Undo undo;
private boolean northSouth = true; private boolean northSouth = true;
@ -20,20 +19,15 @@ public class SetRedstoneFlipBrush extends Brush
/** /**
* *
*/ */
public SetRedstoneFlipBrush() public SetRedstoneFlipBrush() {
{
this.setName("Set Redstone Flip"); this.setName("Set Redstone Flip");
} }
private boolean set(final Block bl) private boolean set(final Block bl) {
{ if (this.block == null) {
if (this.block == null)
{
this.block = bl; this.block = bl;
return true; return true;
} } else {
else
{
this.undo = new Undo(); this.undo = new Undo();
final int lowX = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX(); final int lowX = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX();
final int lowY = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY(); final int lowY = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY();
@ -42,12 +36,9 @@ public class SetRedstoneFlipBrush extends Brush
final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY(); final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY();
final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ(); final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ();
for (int y = lowY; y <= highY; y++) for (int y = lowY; y <= highY; y++) {
{ for (int x = lowX; x <= highX; x++) {
for (int x = lowX; x <= highX; x++) for (int z = lowZ; z <= highZ; z++) {
{
for (int z = lowZ; z <= highZ; z++)
{
this.perform(this.clampY(x, y, z)); this.perform(this.clampY(x, y, z));
} }
} }
@ -58,32 +49,21 @@ public class SetRedstoneFlipBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void perform(final AsyncBlock bl) private void perform(final AsyncBlock bl) {
{ if (bl.getType() == Material.REPEATER) {
if (bl.getType() == Material.REPEATER) if (this.northSouth) {
{ if ((bl.getPropertyId() % 4) == 1) {
if (this.northSouth)
{
if ((bl.getPropertyId() % 4) == 1)
{
this.undo.put(bl); this.undo.put(bl);
bl.setPropertyId((bl.getPropertyId() + 2)); bl.setPropertyId((bl.getPropertyId() + 2));
} } else if ((bl.getPropertyId() % 4) == 3) {
else if ((bl.getPropertyId() % 4) == 3)
{
this.undo.put(bl); this.undo.put(bl);
bl.setPropertyId((bl.getPropertyId() - 2)); bl.setPropertyId((bl.getPropertyId() - 2));
} }
} } else {
else if ((bl.getPropertyId() % 4) == 2) {
{
if ((bl.getPropertyId() % 4) == 2)
{
this.undo.put(bl); this.undo.put(bl);
bl.setPropertyId((bl.getPropertyId() - 2)); bl.setPropertyId((bl.getPropertyId() - 2));
} } else if ((bl.getPropertyId() % 4) == 0) {
else if ((bl.getPropertyId() % 4) == 0)
{
this.undo.put(bl); this.undo.put(bl);
bl.setPropertyId((bl.getPropertyId() + 2)); bl.setPropertyId((bl.getPropertyId() + 2));
} }
@ -92,69 +72,51 @@ public class SetRedstoneFlipBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ if (this.set(this.getTargetBlock())) {
if (this.set(this.getTargetBlock()))
{
v.sendMessage(ChatColor.GRAY + "Point one"); v.sendMessage(ChatColor.GRAY + "Point one");
} } else {
else
{
v.owner().storeUndo(this.undo); v.owner().storeUndo(this.undo);
} }
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (this.set(this.getLastBlock())) {
if (this.set(this.getLastBlock()))
{
v.sendMessage(ChatColor.GRAY + "Point one"); v.sendMessage(ChatColor.GRAY + "Point one");
} } else {
else
{
v.owner().storeUndo(this.undo); v.owner().storeUndo(this.undo);
} }
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
this.block = null; this.block = null;
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++) if (par[i].equalsIgnoreCase("info")) {
{
if (par[i].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Set Repeater Flip Parameters:"); v.sendMessage(ChatColor.GOLD + "Set Repeater Flip Parameters:");
v.sendMessage(ChatColor.AQUA + "/b setrf <direction> -- valid direction inputs are(n,s,e,world), Set the direction that you wish to flip your repeaters, defaults to north/south."); v.sendMessage(ChatColor.AQUA + "/b setrf <direction> -- valid direction inputs are(n,s,e,world), Set the direction that you wish to flip your repeaters, defaults to north/south.");
return; return;
} }
if (par[i].startsWith("n") || par[i].startsWith("s") || par[i].startsWith("ns")) if (par[i].startsWith("n") || par[i].startsWith("s") || par[i].startsWith("ns")) {
{
this.northSouth = true; this.northSouth = true;
v.sendMessage(ChatColor.AQUA + "Flip direction set to north/south"); v.sendMessage(ChatColor.AQUA + "Flip direction set to north/south");
} } else if (par[i].startsWith("e") || par[i].startsWith("world") || par[i].startsWith("ew")) {
else if (par[i].startsWith("e") || par[i].startsWith("world") || par[i].startsWith("ew"))
{
this.northSouth = false; this.northSouth = false;
v.sendMessage(ChatColor.AQUA + "Flip direction set to east/west."); v.sendMessage(ChatColor.AQUA + "Flip direction set to east/west.");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.setredstoneflip"; return "voxelsniper.brush.setredstoneflip";
} }
} }

Datei anzeigen

@ -11,28 +11,22 @@ import org.bukkit.block.Block;
/** /**
* @author Voxel * @author Voxel
*/ */
public class SetRedstoneRotateBrush extends Brush public class SetRedstoneRotateBrush extends Brush {
{
private Block block = null; private Block block = null;
private Undo undo; private Undo undo;
/** /**
* *
*/ */
public SetRedstoneRotateBrush() public SetRedstoneRotateBrush() {
{
this.setName("Set Redstone Rotate"); this.setName("Set Redstone Rotate");
} }
private boolean set(final Block bl) private boolean set(final Block bl) {
{ if (this.block == null) {
if (this.block == null)
{
this.block = bl; this.block = bl;
return true; return true;
} } else {
else
{
this.undo = new Undo(); this.undo = new Undo();
final int lowX = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX(); final int lowX = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX();
final int lowY = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY(); final int lowY = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY();
@ -41,12 +35,9 @@ public class SetRedstoneRotateBrush extends Brush
final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY(); final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY();
final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ(); final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ();
for (int y = lowY; y <= highY; y++) for (int y = lowY; y <= highY; y++) {
{ for (int x = lowX; x <= highX; x++) {
for (int x = lowX; x <= highX; x++) for (int z = lowZ; z <= highZ; z++) {
{
for (int z = lowZ; z <= highZ; z++)
{
this.perform(this.clampY(x, y, z)); this.perform(this.clampY(x, y, z));
} }
} }
@ -57,57 +48,44 @@ public class SetRedstoneRotateBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void perform(final AsyncBlock bl) private void perform(final AsyncBlock bl) {
{ if (bl.getType() == Material.REPEATER) {
if (bl.getType() == Material.REPEATER)
{
this.undo.put(bl); this.undo.put(bl);
bl.setPropertyId((((bl.getPropertyId() % 4) + 1 < 5) ? (bl.getPropertyId() + 1) : (bl.getPropertyId() - 4))); bl.setPropertyId((((bl.getPropertyId() % 4) + 1 < 5) ? (bl.getPropertyId() + 1) : (bl.getPropertyId() - 4)));
} }
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ if (this.set(this.getTargetBlock())) {
if (this.set(this.getTargetBlock()))
{
v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one"); v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one");
} } else {
else
{
v.owner().storeUndo(this.undo); v.owner().storeUndo(this.undo);
} }
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (this.set(this.getLastBlock())) {
if (this.set(this.getLastBlock()))
{
v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one"); v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one");
} } else {
else
{
v.owner().storeUndo(this.undo); v.owner().storeUndo(this.undo);
} }
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
this.block = null; this.block = null;
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{
super.parameters(par, v); super.parameters(par, v);
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.setredstonerotate"; return "voxelsniper.brush.setredstonerotate";
} }
} }

Datei anzeigen

@ -12,19 +12,16 @@ import org.bukkit.block.Block;
* *
* @author Voxel * @author Voxel
*/ */
public class ShellBallBrush extends Brush public class ShellBallBrush extends Brush {
{
/** /**
* *
*/ */
public ShellBallBrush() public ShellBallBrush() {
{
this.setName("Shell Ball"); this.setName("Shell Ball");
} }
// parameters isn't an abstract method, gilt. You can just leave it out if there are none. // parameters isn't an abstract method, gilt. You can just leave it out if there are none.
private void bShell(final SnipeData v, Block targetBlock) private void bShell(final SnipeData v, Block targetBlock) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final int brushSizeDoubled = 2 * brushSize; final int brushSizeDoubled = 2 * brushSize;
final int[][][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer final int[][][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer
@ -34,65 +31,50 @@ public class ShellBallBrush extends Brush
int blockPositionY = targetBlock.getY(); int blockPositionY = targetBlock.getY();
int blockPositionZ = targetBlock.getZ(); int blockPositionZ = targetBlock.getZ();
// Log current materials into oldmats // Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++) for (int x = 0; x <= 2 * (brushSize + 1); x++) {
{ for (int y = 0; y <= 2 * (brushSize + 1); y++) {
for (int y = 0; y <= 2 * (brushSize + 1); y++) for (int z = 0; z <= 2 * (brushSize + 1); z++) {
{
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
oldMaterials[x][y][z] = this.getBlockIdAt(blockPositionX - brushSize - 1 + x, blockPositionY - brushSize - 1 + y, blockPositionZ - brushSize - 1 + z); oldMaterials[x][y][z] = this.getBlockIdAt(blockPositionX - brushSize - 1 + x, blockPositionY - brushSize - 1 + y, blockPositionZ - brushSize - 1 + z);
} }
} }
} }
// Log current materials into newmats // Log current materials into newmats
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{ for (int y = 0; y <= brushSizeDoubled; y++) {
for (int y = 0; y <= brushSizeDoubled; y++)
{
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0, System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
brushSizeDoubled + 1); brushSizeDoubled + 1);
} }
} }
int temp; int temp;
// Hollow Brush Area // Hollow Brush Area
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{ for (int y = 0; y <= brushSizeDoubled; y++) {
for (int y = 0; y <= brushSizeDoubled; y++) for (int z = 0; z <= brushSizeDoubled; z++) {
{
for (int z = 0; z <= brushSizeDoubled; z++)
{
temp = 0; temp = 0;
if (oldMaterials[x + 1 + 1][y + 1][z + 1] == v.getReplaceId()) if (oldMaterials[x + 1 + 1][y + 1][z + 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (oldMaterials[x + 1 - 1][y + 1][z + 1] == v.getReplaceId()) if (oldMaterials[x + 1 - 1][y + 1][z + 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (oldMaterials[x + 1][y + 1 + 1][z + 1] == v.getReplaceId()) if (oldMaterials[x + 1][y + 1 + 1][z + 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (oldMaterials[x + 1][y + 1 - 1][z + 1] == v.getReplaceId()) if (oldMaterials[x + 1][y + 1 - 1][z + 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (oldMaterials[x + 1][y + 1][z + 1 + 1] == v.getReplaceId()) if (oldMaterials[x + 1][y + 1][z + 1 + 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (oldMaterials[x + 1][y + 1][z + 1 - 1] == v.getReplaceId()) if (oldMaterials[x + 1][y + 1][z + 1 - 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (temp == 0) if (temp == 0) {
{
newMaterials[x][y][z] = v.getVoxelId(); newMaterials[x][y][z] = v.getVoxelId();
} }
} }
@ -103,20 +85,15 @@ public class ShellBallBrush extends Brush
final Undo undo = new Undo(); final Undo undo = new Undo();
final double rSquared = Math.pow(brushSize + 0.5, 2); final double rSquared = Math.pow(brushSize + 0.5, 2);
for (int x = brushSizeDoubled; x >= 0; x--) for (int x = brushSizeDoubled; x >= 0; x--) {
{
final double xSquared = Math.pow(x - brushSize, 2); final double xSquared = Math.pow(x - brushSize, 2);
for (int y = 0; y <= 2 * brushSize; y++) for (int y = 0; y <= 2 * brushSize; y++) {
{
final double ySquared = Math.pow(y - brushSize, 2); final double ySquared = Math.pow(y - brushSize, 2);
for (int z = 2 * brushSize; z >= 0; z--) for (int z = 2 * brushSize; z >= 0; z--) {
{ if (xSquared + ySquared + Math.pow(z - brushSize, 2) <= rSquared) {
if (xSquared + ySquared + Math.pow(z - brushSize, 2) <= rSquared) if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z) != newMaterials[x][y][z]) {
{
if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z) != newMaterials[x][y][z])
{
undo.put(this.clampY(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z)); undo.put(this.clampY(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z));
} }
this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - brushSize + y, newMaterials[x][y][z]); this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - brushSize + y, newMaterials[x][y][z]);
@ -131,20 +108,17 @@ public class ShellBallBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.bShell(v, this.getTargetBlock()); this.bShell(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.bShell(v, this.getLastBlock()); this.bShell(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.voxel(); vm.voxel();
@ -152,8 +126,7 @@ public class ShellBallBrush extends Brush
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.shellball"; return "voxelsniper.brush.shellball";
} }
} }

Datei anzeigen

@ -14,31 +14,24 @@ import java.util.ArrayList;
* *
* @author Piotr * @author Piotr
*/ */
public class ShellSetBrush extends Brush public class ShellSetBrush extends Brush {
{
private static final int MAX_SIZE = 5000000; private static final int MAX_SIZE = 5000000;
private Block block = null; private Block block = null;
/** /**
* *
*/ */
public ShellSetBrush() public ShellSetBrush() {
{
this.setName("Shell Set"); this.setName("Shell Set");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private boolean set(final Block bl, final SnipeData v) private boolean set(final Block bl, final SnipeData v) {
{ if (this.block == null) {
if (this.block == null)
{
this.block = bl; this.block = bl;
return true; return true;
} } else {
else if (!this.block.getWorld().getName().equals(bl.getWorld().getName())) {
{
if (!this.block.getWorld().getName().equals(bl.getWorld().getName()))
{
v.sendMessage(ChatColor.RED + "You selected points in different worlds!"); v.sendMessage(ChatColor.RED + "You selected points in different worlds!");
this.block = null; this.block = null;
return true; return true;
@ -51,50 +44,29 @@ public class ShellSetBrush extends Brush
final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY(); final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY();
final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ(); final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ();
if (Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY) > MAX_SIZE) if (Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY) > MAX_SIZE) {
{
v.sendMessage(ChatColor.RED + "Selection size above hardcoded limit, please use a smaller selection."); v.sendMessage(ChatColor.RED + "Selection size above hardcoded limit, please use a smaller selection.");
} } else {
else
{
final ArrayList<AsyncBlock> blocks = new ArrayList<>( final ArrayList<AsyncBlock> blocks = new ArrayList<>(
((Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY)) / 2)); ((Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY)) / 2));
for (int y = lowY; y <= highY; y++) for (int y = lowY; y <= highY; y++) {
{ for (int x = lowX; x <= highX; x++) {
for (int x = lowX; x <= highX; x++) for (int z = lowZ; z <= highZ; z++) {
{ if (this.getWorld().getBlockAt(x, y, z).getTypeId() == v.getReplaceId()) {
for (int z = lowZ; z <= highZ; z++)
{
if (this.getWorld().getBlockAt(x, y, z).getTypeId() == v.getReplaceId())
{
continue; continue;
} } else if (this.getWorld().getBlockAt(x + 1, y, z).getTypeId() == v.getReplaceId()) {
else if (this.getWorld().getBlockAt(x + 1, y, z).getTypeId() == v.getReplaceId())
{
continue; continue;
} } else if (this.getWorld().getBlockAt(x - 1, y, z).getTypeId() == v.getReplaceId()) {
else if (this.getWorld().getBlockAt(x - 1, y, z).getTypeId() == v.getReplaceId())
{
continue; continue;
} } else if (this.getWorld().getBlockAt(x, y, z + 1).getTypeId() == v.getReplaceId()) {
else if (this.getWorld().getBlockAt(x, y, z + 1).getTypeId() == v.getReplaceId())
{
continue; continue;
} } else if (this.getWorld().getBlockAt(x, y, z - 1).getTypeId() == v.getReplaceId()) {
else if (this.getWorld().getBlockAt(x, y, z - 1).getTypeId() == v.getReplaceId())
{
continue; continue;
} } else if (this.getWorld().getBlockAt(x, y + 1, z).getTypeId() == v.getReplaceId()) {
else if (this.getWorld().getBlockAt(x, y + 1, z).getTypeId() == v.getReplaceId())
{
continue; continue;
} } else if (this.getWorld().getBlockAt(x, y - 1, z).getTypeId() == v.getReplaceId()) {
else if (this.getWorld().getBlockAt(x, y - 1, z).getTypeId() == v.getReplaceId())
{
continue; continue;
} } else {
else
{
blocks.add(this.getWorld().getBlockAt(x, y, z)); blocks.add(this.getWorld().getBlockAt(x, y, z));
} }
} }
@ -102,10 +74,8 @@ public class ShellSetBrush extends Brush
} }
final Undo undo = new Undo(); final Undo undo = new Undo();
for (final AsyncBlock currentBlock : blocks) for (final AsyncBlock currentBlock : blocks) {
{ if (currentBlock.getTypeId() != v.getVoxelId()) {
if (currentBlock.getTypeId() != v.getVoxelId())
{
undo.put(currentBlock); undo.put(currentBlock);
currentBlock.setTypeId(v.getVoxelId()); currentBlock.setTypeId(v.getVoxelId());
} }
@ -120,26 +90,21 @@ public class ShellSetBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ if (this.set(this.getTargetBlock(), v)) {
if (this.set(this.getTargetBlock(), v))
{
v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one"); v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one");
} }
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (this.set(this.getLastBlock(), v)) {
if (this.set(this.getLastBlock(), v))
{
v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one"); v.owner().getPlayer().sendMessage(ChatColor.GRAY + "Point one");
} }
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.voxel(); vm.voxel();
@ -147,8 +112,7 @@ public class ShellSetBrush extends Brush
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.shellset"; return "voxelsniper.brush.shellset";
} }
} }

Datei anzeigen

@ -12,18 +12,15 @@ import org.bukkit.block.Block;
* *
* @author Voxel * @author Voxel
*/ */
public class ShellVoxelBrush extends Brush public class ShellVoxelBrush extends Brush {
{
/** /**
* *
*/ */
public ShellVoxelBrush() public ShellVoxelBrush() {
{
this.setName("Shell Voxel"); this.setName("Shell Voxel");
} }
private void vShell(final SnipeData v, Block targetBlock) private void vShell(final SnipeData v, Block targetBlock) {
{
final int brushSize = v.getBrushSize(); final int brushSize = v.getBrushSize();
final int brushSizeSquared = 2 * brushSize; final int brushSizeSquared = 2 * brushSize;
final int[][][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer final int[][][] oldMaterials = new int[2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1][2 * (brushSize + 1) + 1]; // Array that holds the original materials plus a buffer
@ -33,64 +30,49 @@ public class ShellVoxelBrush extends Brush
int blockPositionY = targetBlock.getY(); int blockPositionY = targetBlock.getY();
int blockPositionZ = targetBlock.getZ(); int blockPositionZ = targetBlock.getZ();
// Log current materials into oldmats // Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++) for (int x = 0; x <= 2 * (brushSize + 1); x++) {
{ for (int y = 0; y <= 2 * (brushSize + 1); y++) {
for (int y = 0; y <= 2 * (brushSize + 1); y++) for (int z = 0; z <= 2 * (brushSize + 1); z++) {
{
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
oldMaterials[x][y][z] = this.getBlockIdAt(blockPositionX - brushSize - 1 + x, blockPositionY - brushSize - 1 + y, blockPositionZ - brushSize - 1 + z); oldMaterials[x][y][z] = this.getBlockIdAt(blockPositionX - brushSize - 1 + x, blockPositionY - brushSize - 1 + y, blockPositionZ - brushSize - 1 + z);
} }
} }
} }
// Log current materials into newmats // Log current materials into newmats
for (int x = 0; x <= brushSizeSquared; x++) for (int x = 0; x <= brushSizeSquared; x++) {
{ for (int y = 0; y <= brushSizeSquared; y++) {
for (int y = 0; y <= brushSizeSquared; y++)
{
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0, System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
brushSizeSquared + 1); brushSizeSquared + 1);
} }
} }
int temp; int temp;
// Hollow Brush Area // Hollow Brush Area
for (int x = 0; x <= brushSizeSquared; x++) for (int x = 0; x <= brushSizeSquared; x++) {
{ for (int z = 0; z <= brushSizeSquared; z++) {
for (int z = 0; z <= brushSizeSquared; z++) for (int y = 0; y <= brushSizeSquared; y++) {
{
for (int y = 0; y <= brushSizeSquared; y++)
{
temp = 0; temp = 0;
if (oldMaterials[x + 1 + 1][z + 1][y + 1] == v.getReplaceId()) if (oldMaterials[x + 1 + 1][z + 1][y + 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (oldMaterials[x + 1 - 1][z + 1][y + 1] == v.getReplaceId()) if (oldMaterials[x + 1 - 1][z + 1][y + 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (oldMaterials[x + 1][z + 1 + 1][y + 1] == v.getReplaceId()) if (oldMaterials[x + 1][z + 1 + 1][y + 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (oldMaterials[x + 1][z + 1 - 1][y + 1] == v.getReplaceId()) if (oldMaterials[x + 1][z + 1 - 1][y + 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (oldMaterials[x + 1][z + 1][y + 1 + 1] == v.getReplaceId()) if (oldMaterials[x + 1][z + 1][y + 1 + 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (oldMaterials[x + 1][z + 1][y + 1 - 1] == v.getReplaceId()) if (oldMaterials[x + 1][z + 1][y + 1 - 1] == v.getReplaceId()) {
{
temp++; temp++;
} }
if (temp == 0) if (temp == 0) {
{
newMaterials[x][z][y] = v.getVoxelId(); newMaterials[x][z][y] = v.getVoxelId();
} }
} }
@ -100,14 +82,10 @@ public class ShellVoxelBrush extends Brush
// Make the changes // Make the changes
final Undo undo = new Undo(); final Undo undo = new Undo();
for (int x = brushSizeSquared; x >= 0; x--) for (int x = brushSizeSquared; x >= 0; x--) {
{ for (int y = 0; y <= brushSizeSquared; y++) {
for (int y = 0; y <= brushSizeSquared; y++) for (int z = brushSizeSquared; z >= 0; z--) {
{ if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z) != newMaterials[x][y][z]) {
for (int z = brushSizeSquared; z >= 0; z--)
{
if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z) != newMaterials[x][y][z])
{
undo.put(this.clampY(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z)); undo.put(this.clampY(blockPositionX - brushSize + x, blockPositionY - brushSize + y, blockPositionZ - brushSize + z));
} }
this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - brushSize + y, newMaterials[x][y][z]); this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - brushSize + y, newMaterials[x][y][z]);
@ -120,20 +98,17 @@ public class ShellVoxelBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.vShell(v, this.getTargetBlock()); this.vShell(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.vShell(v, this.getLastBlock()); this.vShell(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
vm.voxel(); vm.voxel();
@ -141,21 +116,16 @@ public class ShellVoxelBrush extends Brush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Shell Voxel Parameters:"); v.sendMessage(ChatColor.GOLD + "Shell Voxel Parameters:");
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid parameter - see the info message for help."); v.sendMessage(ChatColor.RED + "Invalid parameter - see the info message for help.");
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.shellvoxel"; return "voxelsniper.brush.shellvoxel";
} }
} }

Datei anzeigen

@ -7,12 +7,7 @@ import org.bukkit.ChatColor;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import java.io.BufferedReader; import java.io.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
/** /**
* Overwrites signs. (Wiki: * Overwrites signs. (Wiki:
@ -20,8 +15,7 @@ import java.io.IOException;
* *
* @author Monofraps * @author Monofraps
*/ */
public class SignOverwriteBrush extends Brush public class SignOverwriteBrush extends Brush {
{
private static final int MAX_SIGN_LINE_LENGTH = 15; private static final int MAX_SIGN_LINE_LENGTH = 15;
private static final int NUM_SIGN_LINES = 4; private static final int NUM_SIGN_LINES = 4;
// these are no array indices // these are no array indices
@ -36,8 +30,7 @@ public class SignOverwriteBrush extends Brush
/** /**
* *
*/ */
public SignOverwriteBrush() public SignOverwriteBrush() {
{
this.setName("Sign Overwrite Brush"); this.setName("Sign Overwrite Brush");
clearBuffer(); clearBuffer();
@ -49,12 +42,9 @@ public class SignOverwriteBrush extends Brush
* *
* @param sign * @param sign
*/ */
private void setSignText(final Sign sign) private void setSignText(final Sign sign) {
{ for (int i = 0; i < this.signTextLines.length; i++) {
for (int i = 0; i < this.signTextLines.length; i++) if (this.signLinesEnabled[i]) {
{
if (this.signLinesEnabled[i])
{
sign.setLine(i, this.signTextLines[i]); sign.setLine(i, this.signTextLines[i]);
} }
} }
@ -67,14 +57,10 @@ public class SignOverwriteBrush extends Brush
* *
* @param v * @param v
*/ */
private void setSingle(final SnipeData v) private void setSingle(final SnipeData v) {
{ if (this.getTargetBlock().getState() instanceof Sign) {
if (this.getTargetBlock().getState() instanceof Sign)
{
setSignText((Sign) this.getTargetBlock().getState()); setSignText((Sign) this.getTargetBlock().getState());
} } else {
else
{
v.sendMessage(ChatColor.RED + "Target block is not a sign."); v.sendMessage(ChatColor.RED + "Target block is not a sign.");
return; return;
} }
@ -85,8 +71,7 @@ public class SignOverwriteBrush extends Brush
* *
* @param v * @param v
*/ */
private void setRanged(final SnipeData v) private void setRanged(final SnipeData v) {
{
final int minX = getTargetBlock().getX() - v.getBrushSize(); final int minX = getTargetBlock().getX() - v.getBrushSize();
final int maxX = getTargetBlock().getX() + v.getBrushSize(); final int maxX = getTargetBlock().getX() + v.getBrushSize();
final int minY = getTargetBlock().getY() - v.getVoxelHeight(); final int minY = getTargetBlock().getY() - v.getVoxelHeight();
@ -96,15 +81,11 @@ public class SignOverwriteBrush extends Brush
boolean signFound = false; // indicates whether or not a sign was set boolean signFound = false; // indicates whether or not a sign was set
for (int x = minX; x <= maxX; x++) for (int x = minX; x <= maxX; x++) {
{ for (int y = minY; y <= maxY; y++) {
for (int y = minY; y <= maxY; y++) for (int z = minZ; z <= maxZ; z++) {
{
for (int z = minZ; z <= maxZ; z++)
{
BlockState blockState = this.getWorld().getBlockAt(x, y, z).getState(); BlockState blockState = this.getWorld().getBlockAt(x, y, z).getState();
if (blockState instanceof Sign) if (blockState instanceof Sign) {
{
setSignText((Sign) blockState); setSignText((Sign) blockState);
signFound = true; signFound = true;
} }
@ -112,61 +93,46 @@ public class SignOverwriteBrush extends Brush
} }
} }
if (!signFound) if (!signFound) {
{
v.sendMessage(ChatColor.RED + "Did not found any sign in selection box."); v.sendMessage(ChatColor.RED + "Did not found any sign in selection box.");
} }
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ if (this.rangedMode) {
if (this.rangedMode)
{
setRanged(v); setRanged(v);
} } else {
else
{
setSingle(v); setSingle(v);
} }
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (this.getTargetBlock().getState() instanceof Sign) {
if (this.getTargetBlock().getState() instanceof Sign)
{
Sign sign = (Sign) this.getTargetBlock().getState(); Sign sign = (Sign) this.getTargetBlock().getState();
for (int i = 0; i < this.signTextLines.length; i++) for (int i = 0; i < this.signTextLines.length; i++) {
{ if (this.signLinesEnabled[i]) {
if (this.signLinesEnabled[i])
{
this.signTextLines[i] = sign.getLine(i); this.signTextLines[i] = sign.getLine(i);
} }
} }
displayBuffer(v); displayBuffer(v);
} } else {
else
{
v.sendMessage(ChatColor.RED + "Target block is not a sign."); v.sendMessage(ChatColor.RED + "Target block is not a sign.");
} }
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{
boolean textChanged = false; boolean textChanged = false;
for (int i = 0; i < par.length; i++) for (int i = 0; i < par.length; i++) {
{
String parameter = par[i]; String parameter = par[i];
try try {
{ if (parameter.equalsIgnoreCase("info")) {
if (parameter.equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.AQUA + "Sign Overwrite Brush Powder/Arrow:"); v.sendMessage(ChatColor.AQUA + "Sign Overwrite Brush Powder/Arrow:");
v.sendMessage(ChatColor.BLUE + "The arrow writes the internal line buffer to the tearget sign."); v.sendMessage(ChatColor.BLUE + "The arrow writes the internal line buffer to the tearget sign.");
v.sendMessage(ChatColor.BLUE + "The powder reads the text of the target sign into the internal buffer."); v.sendMessage(ChatColor.BLUE + "The powder reads the text of the target sign into the internal buffer.");
@ -180,69 +146,47 @@ public class SignOverwriteBrush extends Brush
v.sendMessage(ChatColor.GREEN + "-multiple [on|off] " + ChatColor.BLUE + "-- Enables or disables ranged mode. (Alias: -m) (see Wiki for more information)"); v.sendMessage(ChatColor.GREEN + "-multiple [on|off] " + ChatColor.BLUE + "-- Enables or disables ranged mode. (Alias: -m) (see Wiki for more information)");
v.sendMessage(ChatColor.GREEN + "-save (name) " + ChatColor.BLUE + "-- Save you buffer to a file named [name]. (Alias: -s)"); v.sendMessage(ChatColor.GREEN + "-save (name) " + ChatColor.BLUE + "-- Save you buffer to a file named [name]. (Alias: -s)");
v.sendMessage(ChatColor.GREEN + "-open (name) " + ChatColor.BLUE + "-- Loads a buffer from a file named [name]. (Alias: -o)"); v.sendMessage(ChatColor.GREEN + "-open (name) " + ChatColor.BLUE + "-- Loads a buffer from a file named [name]. (Alias: -o)");
} } else if (parameter.startsWith("-1")) {
else if (parameter.startsWith("-1"))
{
textChanged = true; textChanged = true;
i = parseSignLineFromParam(par, SIGN_LINE_1, v, i); i = parseSignLineFromParam(par, SIGN_LINE_1, v, i);
} } else if (parameter.startsWith("-2")) {
else if (parameter.startsWith("-2"))
{
textChanged = true; textChanged = true;
i = parseSignLineFromParam(par, SIGN_LINE_2, v, i); i = parseSignLineFromParam(par, SIGN_LINE_2, v, i);
} } else if (parameter.startsWith("-3")) {
else if (parameter.startsWith("-3"))
{
textChanged = true; textChanged = true;
i = parseSignLineFromParam(par, SIGN_LINE_3, v, i); i = parseSignLineFromParam(par, SIGN_LINE_3, v, i);
} } else if (parameter.startsWith("-4")) {
else if (parameter.startsWith("-4"))
{
textChanged = true; textChanged = true;
i = parseSignLineFromParam(par, SIGN_LINE_4, v, i); i = parseSignLineFromParam(par, SIGN_LINE_4, v, i);
} } else if (parameter.equalsIgnoreCase("-clear") || parameter.equalsIgnoreCase("-c")) {
else if (parameter.equalsIgnoreCase("-clear") || parameter.equalsIgnoreCase("-c"))
{
clearBuffer(); clearBuffer();
v.sendMessage(ChatColor.BLUE + "Internal text buffer cleard."); v.sendMessage(ChatColor.BLUE + "Internal text buffer cleard.");
} } else if (parameter.equalsIgnoreCase("-clearall") || parameter.equalsIgnoreCase("-ca")) {
else if (parameter.equalsIgnoreCase("-clearall") || parameter.equalsIgnoreCase("-ca"))
{
clearBuffer(); clearBuffer();
resetStates(); resetStates();
v.sendMessage(ChatColor.BLUE + "Internal text buffer cleard and states back to enabled."); v.sendMessage(ChatColor.BLUE + "Internal text buffer cleard and states back to enabled.");
} } else if (parameter.equalsIgnoreCase("-multiple") || parameter.equalsIgnoreCase("-m")) {
else if (parameter.equalsIgnoreCase("-multiple") || parameter.equalsIgnoreCase("-m")) if ((i + 1) >= par.length) {
{
if ((i + 1) >= par.length)
{
v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter)); v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter));
continue; continue;
} }
rangedMode = (par[++i].equalsIgnoreCase("on") || par[++i].equalsIgnoreCase("yes")); rangedMode = (par[++i].equalsIgnoreCase("on") || par[++i].equalsIgnoreCase("yes"));
v.sendMessage(ChatColor.BLUE + String.format("Ranged mode is %s", ChatColor.GREEN + (rangedMode ? "enabled" : "disabled"))); v.sendMessage(ChatColor.BLUE + String.format("Ranged mode is %s", ChatColor.GREEN + (rangedMode ? "enabled" : "disabled")));
if (this.rangedMode) if (this.rangedMode) {
{
v.sendMessage(ChatColor.GREEN + "Brush size set to " + ChatColor.RED + v.getBrushSize()); v.sendMessage(ChatColor.GREEN + "Brush size set to " + ChatColor.RED + v.getBrushSize());
v.sendMessage(ChatColor.AQUA + "Brush height set to " + ChatColor.RED + v.getVoxelHeight()); v.sendMessage(ChatColor.AQUA + "Brush height set to " + ChatColor.RED + v.getVoxelHeight());
} }
} } else if (parameter.equalsIgnoreCase("-save") || parameter.equalsIgnoreCase("-s")) {
else if (parameter.equalsIgnoreCase("-save") || parameter.equalsIgnoreCase("-s")) if ((i + 1) >= par.length) {
{
if ((i + 1) >= par.length)
{
v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter)); v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter));
continue; continue;
} }
String fileName = par[++i]; String fileName = par[++i];
saveBufferToFile(fileName, v); saveBufferToFile(fileName, v);
} } else if (parameter.equalsIgnoreCase("-open") || parameter.equalsIgnoreCase("-o")) {
else if (parameter.equalsIgnoreCase("-open") || parameter.equalsIgnoreCase("-o")) if ((i + 1) >= par.length) {
{
if ((i + 1) >= par.length)
{
v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter)); v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter));
continue; continue;
} }
@ -251,16 +195,13 @@ public class SignOverwriteBrush extends Brush
loadBufferFromFile(fileName, "", v); loadBufferFromFile(fileName, "", v);
textChanged = true; textChanged = true;
} }
} } catch (Exception exception) {
catch (Exception exception)
{
v.sendMessage(ChatColor.RED + String.format("Error while parsing parameter %s", parameter)); v.sendMessage(ChatColor.RED + String.format("Error while parsing parameter %s", parameter));
exception.printStackTrace(); exception.printStackTrace();
} }
} }
if (textChanged) if (textChanged) {
{
displayBuffer(v); displayBuffer(v);
} }
} }
@ -276,25 +217,21 @@ public class SignOverwriteBrush extends Brush
* @param i * @param i
* @return * @return
*/ */
private int parseSignLineFromParam(final String[] params, final int lineNumber, final SnipeData v, int i) private int parseSignLineFromParam(final String[] params, final int lineNumber, final SnipeData v, int i) {
{
final int lineIndex = lineNumber - 1; final int lineIndex = lineNumber - 1;
final String parameter = params[i]; final String parameter = params[i];
boolean statusSet = false; boolean statusSet = false;
if (parameter.contains(":")) if (parameter.contains(":")) {
{
this.signLinesEnabled[lineIndex] = parameter.substring(parameter.indexOf(":")).equalsIgnoreCase(":enabled"); this.signLinesEnabled[lineIndex] = parameter.substring(parameter.indexOf(":")).equalsIgnoreCase(":enabled");
v.sendMessage(ChatColor.BLUE + "Line " + lineNumber + " is " + ChatColor.GREEN + (this.signLinesEnabled[lineIndex] ? "enabled" : "disabled")); v.sendMessage(ChatColor.BLUE + "Line " + lineNumber + " is " + ChatColor.GREEN + (this.signLinesEnabled[lineIndex] ? "enabled" : "disabled"));
statusSet = true; statusSet = true;
} }
if ((i + 1) >= params.length) if ((i + 1) >= params.length) {
{
// return if the user just wanted to set the status // return if the user just wanted to set the status
if (statusSet) if (statusSet) {
{
return i; return i;
} }
@ -306,17 +243,13 @@ public class SignOverwriteBrush extends Brush
String newText = ""; String newText = "";
// go through the array until the next top level parameter is found // go through the array until the next top level parameter is found
for (i++; i < params.length; i++) for (i++; i < params.length; i++) {
{
final String currentParameter = params[i]; final String currentParameter = params[i];
if (currentParameter.startsWith("-")) if (currentParameter.startsWith("-")) {
{
i--; i--;
break; break;
} } else {
else
{
newText += currentParameter + " "; newText += currentParameter + " ";
} }
} }
@ -324,22 +257,17 @@ public class SignOverwriteBrush extends Brush
newText = ChatColor.translateAlternateColorCodes('&', newText); newText = ChatColor.translateAlternateColorCodes('&', newText);
// remove last space or return if the string is empty and the user just wanted to set the status // remove last space or return if the string is empty and the user just wanted to set the status
if (!newText.isEmpty() && newText.endsWith(" ")) if (!newText.isEmpty() && newText.endsWith(" ")) {
{
newText = newText.substring(0, newText.length() - 1); newText = newText.substring(0, newText.length() - 1);
} } else if (newText.isEmpty()) {
else if (newText.isEmpty()) if (statusSet) {
{
if (statusSet)
{
return i; return i;
} }
v.sendMessage(ChatColor.RED + "Warning: No text after -" + lineNumber + ". Setting buffer text to \"\" (empty string)"); v.sendMessage(ChatColor.RED + "Warning: No text after -" + lineNumber + ". Setting buffer text to \"\" (empty string)");
} }
// check the line length and cut the text if needed // check the line length and cut the text if needed
if (newText.length() > MAX_SIGN_LINE_LENGTH) if (newText.length() > MAX_SIGN_LINE_LENGTH) {
{
v.sendMessage(ChatColor.RED + "Warning: Text on line " + lineNumber + " exceeds the maximum line length of " + MAX_SIGN_LINE_LENGTH + " characters. Your text will be cut."); v.sendMessage(ChatColor.RED + "Warning: Text on line " + lineNumber + " exceeds the maximum line length of " + MAX_SIGN_LINE_LENGTH + " characters. Your text will be cut.");
newText = newText.substring(0, MAX_SIGN_LINE_LENGTH); newText = newText.substring(0, MAX_SIGN_LINE_LENGTH);
} }
@ -348,11 +276,9 @@ public class SignOverwriteBrush extends Brush
return i; return i;
} }
private void displayBuffer(final SnipeData v) private void displayBuffer(final SnipeData v) {
{
v.sendMessage(ChatColor.BLUE + "Buffer text set to: "); v.sendMessage(ChatColor.BLUE + "Buffer text set to: ");
for (int i = 0; i < this.signTextLines.length; i++) for (int i = 0; i < this.signTextLines.length; i++) {
{
v.sendMessage((this.signLinesEnabled[i] ? ChatColor.GREEN + "(E): " : ChatColor.RED + "(D): ") + ChatColor.BLACK + this.signTextLines[i]); v.sendMessage((this.signLinesEnabled[i] ? ChatColor.GREEN + "(E): " : ChatColor.RED + "(D): ") + ChatColor.BLACK + this.signTextLines[i]);
} }
} }
@ -363,24 +289,20 @@ public class SignOverwriteBrush extends Brush
* @param fileName * @param fileName
* @param v * @param v
*/ */
private void saveBufferToFile(final String fileName, final SnipeData v) private void saveBufferToFile(final String fileName, final SnipeData v) {
{
final File store = new File(VoxelSniper.getInstance().getDataFolder() + "/" + fileName + ".vsign"); final File store = new File(VoxelSniper.getInstance().getDataFolder() + "/" + fileName + ".vsign");
if (store.exists()) if (store.exists()) {
{
v.sendMessage("This file already exists."); v.sendMessage("This file already exists.");
return; return;
} }
try try {
{
store.createNewFile(); store.createNewFile();
FileWriter outFile = new FileWriter(store); FileWriter outFile = new FileWriter(store);
BufferedWriter outStream = new BufferedWriter(outFile); BufferedWriter outStream = new BufferedWriter(outFile);
for (int i = 0; i < this.signTextLines.length; i++) for (int i = 0; i < this.signTextLines.length; i++) {
{ outStream.write(this.signLinesEnabled[i] + "\n");
outStream.write(String.valueOf(this.signLinesEnabled[i]) + "\n");
outStream.write(this.signTextLines[i] + "\n"); outStream.write(this.signTextLines[i] + "\n");
} }
@ -388,9 +310,7 @@ public class SignOverwriteBrush extends Brush
outFile.close(); outFile.close();
v.sendMessage(ChatColor.BLUE + "File saved successfully."); v.sendMessage(ChatColor.BLUE + "File saved successfully.");
} } catch (IOException exception) {
catch (IOException exception)
{
v.sendMessage(ChatColor.RED + "Failed to save file. " + exception.getMessage()); v.sendMessage(ChatColor.RED + "Failed to save file. " + exception.getMessage());
exception.printStackTrace(); exception.printStackTrace();
} }
@ -403,22 +323,18 @@ public class SignOverwriteBrush extends Brush
* @param userDomain * @param userDomain
* @param v * @param v
*/ */
private void loadBufferFromFile(final String fileName, final String userDomain, final SnipeData v) private void loadBufferFromFile(final String fileName, final String userDomain, final SnipeData v) {
{
final File store = new File(VoxelSniper.getInstance().getDataFolder() + "/" + fileName + ".vsign"); final File store = new File(VoxelSniper.getInstance().getDataFolder() + "/" + fileName + ".vsign");
if (!store.exists()) if (!store.exists()) {
{
v.sendMessage("This file does not exist."); v.sendMessage("This file does not exist.");
return; return;
} }
try try {
{
FileReader inFile = new FileReader(store); FileReader inFile = new FileReader(store);
BufferedReader inStream = new BufferedReader(inFile); BufferedReader inStream = new BufferedReader(inFile);
for (int i = 0; i < this.signTextLines.length; i++) for (int i = 0; i < this.signTextLines.length; i++) {
{
this.signLinesEnabled[i] = Boolean.valueOf(inStream.readLine()); this.signLinesEnabled[i] = Boolean.valueOf(inStream.readLine());
this.signTextLines[i] = inStream.readLine(); this.signTextLines[i] = inStream.readLine();
} }
@ -427,9 +343,7 @@ public class SignOverwriteBrush extends Brush
inFile.close(); inFile.close();
v.sendMessage(ChatColor.BLUE + "File loaded successfully."); v.sendMessage(ChatColor.BLUE + "File loaded successfully.");
} } catch (IOException exception) {
catch (IOException exception)
{
v.sendMessage(ChatColor.RED + "Failed to load file. " + exception.getMessage()); v.sendMessage(ChatColor.RED + "Failed to load file. " + exception.getMessage());
exception.printStackTrace(); exception.printStackTrace();
} }
@ -438,10 +352,8 @@ public class SignOverwriteBrush extends Brush
/** /**
* Clears the internal text buffer. (Sets it to empty strings) * Clears the internal text buffer. (Sets it to empty strings)
*/ */
private void clearBuffer() private void clearBuffer() {
{ for (int i = 0; i < this.signTextLines.length; i++) {
for (int i = 0; i < this.signTextLines.length; i++)
{
this.signTextLines[i] = ""; this.signTextLines[i] = "";
} }
} }
@ -449,36 +361,30 @@ public class SignOverwriteBrush extends Brush
/** /**
* Resets line enabled states to enabled. * Resets line enabled states to enabled.
*/ */
private void resetStates() private void resetStates() {
{ for (int i = 0; i < this.signLinesEnabled.length; i++) {
for (int i = 0; i < this.signLinesEnabled.length; i++)
{
this.signLinesEnabled[i] = true; this.signLinesEnabled[i] = true;
} }
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName("Sign Overwrite Brush"); vm.brushName("Sign Overwrite Brush");
vm.custom(ChatColor.BLUE + "Buffer text: "); vm.custom(ChatColor.BLUE + "Buffer text: ");
for (int i = 0; i < this.signTextLines.length; i++) for (int i = 0; i < this.signTextLines.length; i++) {
{
vm.custom((this.signLinesEnabled[i] ? ChatColor.GREEN + "(E): " : ChatColor.RED + "(D): ") + ChatColor.BLACK + this.signTextLines[i]); vm.custom((this.signLinesEnabled[i] ? ChatColor.GREEN + "(E): " : ChatColor.RED + "(D): ") + ChatColor.BLACK + this.signTextLines[i]);
} }
vm.custom(ChatColor.BLUE + String.format("Ranged mode is %s", ChatColor.GREEN + (rangedMode ? "enabled" : "disabled"))); vm.custom(ChatColor.BLUE + String.format("Ranged mode is %s", ChatColor.GREEN + (rangedMode ? "enabled" : "disabled")));
if (rangedMode) if (rangedMode) {
{
vm.size(); vm.size();
vm.height(); vm.height();
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.signoverwrite"; return "voxelsniper.brush.signoverwrite";
} }
} }

Datei anzeigen

@ -9,39 +9,33 @@ import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
* *
* @author Voxel * @author Voxel
*/ */
public class SnipeBrush extends PerformBrush public class SnipeBrush extends PerformBrush {
{
/** /**
* *
*/ */
public SnipeBrush() public SnipeBrush() {
{
this.setName("Snipe"); this.setName("Snipe");
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.current.perform(this.getTargetBlock()); this.current.perform(this.getTargetBlock());
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.current.perform(this.getLastBlock()); this.current.perform(this.getLastBlock());
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.snipe"; return "voxelsniper.brush.snipe";
} }
} }

Datei anzeigen

@ -17,21 +17,16 @@ import org.bukkit.block.BlockFace;
* *
* @author Voxel * @author Voxel
*/ */
public class SnowConeBrush extends Brush public class SnowConeBrush extends Brush {
{
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void addSnow(final SnipeData v, Block targetBlock) private void addSnow(final SnipeData v, Block targetBlock) {
{
int brushSize; int brushSize;
int blockPositionX = targetBlock.getX(); int blockPositionX = targetBlock.getX();
int blockPositionY = targetBlock.getY(); int blockPositionY = targetBlock.getY();
int blockPositionZ = targetBlock.getZ(); int blockPositionZ = targetBlock.getZ();
if (targetBlock.isEmpty()) if (targetBlock.isEmpty()) {
{
brushSize = 0; brushSize = 0;
} } else {
else
{
brushSize = this.clampY(blockPositionX, blockPositionY, blockPositionZ).getPropertyId() + 1; brushSize = this.clampY(blockPositionX, blockPositionY, blockPositionZ).getPropertyId() + 1;
} }
@ -41,18 +36,13 @@ public class SnowConeBrush extends Brush
final int[][] yOffset = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; final int[][] yOffset = new int[brushSizeDoubled + 1][brushSizeDoubled + 1];
// prime the arrays // prime the arrays
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{ for (int z = 0; z <= brushSizeDoubled; z++) {
for (int z = 0; z <= brushSizeDoubled; z++)
{
boolean flag = true; boolean flag = true;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++) { // overlay
{ // overlay if (flag) {
if (flag) if ((this.getBlockAt(blockPositionX - brushSize + x, blockPositionY - i, blockPositionZ - brushSize + z).isEmpty() || this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - i, blockPositionZ - brushSize + z) == BlockTypes.SNOW.getInternalId()) && !this.getBlockAt(blockPositionX - brushSize + x, blockPositionY - i - 1, blockPositionZ - brushSize + z).isEmpty() && this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - i - 1, blockPositionZ - brushSize + z) != BlockTypes.SNOW.getInternalId()) {
{
if ((this.getBlockAt(blockPositionX - brushSize + x, blockPositionY - i, blockPositionZ - brushSize + z).isEmpty() || this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - i, blockPositionZ - brushSize + z) == BlockTypes.SNOW.getInternalId()) && !this.getBlockAt(blockPositionX - brushSize + x, blockPositionY - i - 1, blockPositionZ - brushSize + z).isEmpty() && this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - i - 1, blockPositionZ - brushSize + z) != BlockTypes.SNOW.getInternalId())
{
flag = false; flag = false;
yOffset[x][z] = i; yOffset[x][z] = i;
} }
@ -64,40 +54,33 @@ public class SnowConeBrush extends Brush
} }
// figure out new snowheights // figure out new snowheights
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{
final double xSquared = Math.pow(x - brushSize, 2); final double xSquared = Math.pow(x - brushSize, 2);
for (int z = 0; z <= 2 * brushSize; z++) for (int z = 0; z <= 2 * brushSize; z++) {
{
final double zSquared = Math.pow(z - brushSize, 2); final double zSquared = Math.pow(z - brushSize, 2);
final double dist = Math.pow(xSquared + zSquared, .5); // distance from center of array final double dist = Math.pow(xSquared + zSquared, .5); // distance from center of array
final int snowData = brushSize - (int) Math.ceil(dist); final int snowData = brushSize - (int) Math.ceil(dist);
if (snowData >= 0) if (snowData >= 0) { // no funny business
{ // no funny business switch (snowData) {
switch (snowData)
{
case 0: case 0:
if (BlockTypes.get(snowcone[x][z]).getMaterial().isAir()) if (BlockTypes.get(snowcone[x][z]).getMaterial().isAir()) {
{
snowcone[x][z] = BlockTypes.SNOW.getInternalId(); snowcone[x][z] = BlockTypes.SNOW.getInternalId();
snowconeData[x][z] = 0; snowconeData[x][z] = 0;
} }
break; break;
case 7: // Turn largest snowtile into snowblock case 7: // Turn largest snowtile into snowblock
if (snowcone[x][z] == BlockTypes.SNOW.getInternalId()) if (snowcone[x][z] == BlockTypes.SNOW.getInternalId()) {
{
snowcone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId(); snowcone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId();
snowconeData[x][z] = 0; snowconeData[x][z] = 0;
} }
break; break;
default: // Increase snowtile size, if smaller than target default: // Increase snowtile size, if smaller than target
if (snowData > snowconeData[x][z]) if (snowData > snowconeData[x][z]) {
{
BlockType blockType = BlockType blockType =
BlockTypes.get(snowcone[x][z]); BlockTypes.get(snowcone[x][z]);
if (blockType.getMaterial().isAir()) { if (blockType.getMaterial().isAir()) {
snowconeData[x][z] = snowData; snowconeData[x][z] = snowData;
snowcone[x][z] = BlockTypes.SNOW.getInternalId(); snowcone[x][z] = BlockTypes.SNOW.getInternalId();
@ -106,12 +89,9 @@ public class SnowConeBrush extends Brush
} else if (blockType == BlockTypes.SNOW_BLOCK) { } else if (blockType == BlockTypes.SNOW_BLOCK) {
snowconeData[x][z] = snowData; snowconeData[x][z] = snowData;
} }
} } else if (yOffset[x][z] > 0 && snowcone[x][z] == BlockTypes.SNOW.getInternalId()) {
else if (yOffset[x][z] > 0 && snowcone[x][z] == BlockTypes.SNOW.getInternalId())
{
snowconeData[x][z]++; snowconeData[x][z]++;
if (snowconeData[x][z] == 7) if (snowconeData[x][z] == 7) {
{
snowconeData[x][z] = 0; snowconeData[x][z] = 0;
snowcone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId(); snowcone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId();
} }
@ -124,13 +104,10 @@ public class SnowConeBrush extends Brush
final Undo undo = new Undo(); final Undo undo = new Undo();
for (int x = 0; x <= brushSizeDoubled; x++) for (int x = 0; x <= brushSizeDoubled; x++) {
{ for (int z = 0; z <= brushSizeDoubled; z++) {
for (int z = 0; z <= brushSizeDoubled; z++)
{
if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z) != snowcone[x][z] || this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).getPropertyId() != snowconeData[x][z]) if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z) != snowcone[x][z] || this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).getPropertyId() != snowconeData[x][z]) {
{
undo.put(this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z)); undo.put(this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z));
} }
this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], snowcone[x][z]); this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], snowcone[x][z]);
@ -142,45 +119,39 @@ public class SnowConeBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
if (getTargetBlock().getType() == Material.SNOW) { if (getTargetBlock().getType() == Material.SNOW) {
this.addSnow(v, this.getTargetBlock()); this.addSnow(v, this.getTargetBlock());
} else { } else {
Block blockAbove = getTargetBlock().getRelative(BlockFace.UP); Block blockAbove = getTargetBlock().getRelative(BlockFace.UP);
if (blockAbove != null && BukkitAdapter.adapt(blockAbove.getType()).getMaterial() if (blockAbove != null && BukkitAdapter.adapt(blockAbove.getType()).getMaterial()
.isAir()) { .isAir()) {
addSnow(v, blockAbove); addSnow(v, blockAbove);
} else { } else {
v.owner().getPlayer() v.owner().getPlayer()
.sendMessage(ChatColor.RED + "Error: Center block neither snow nor air."); .sendMessage(ChatColor.RED + "Error: Center block neither snow nor air.");
} }
} }
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName("Snow Cone"); vm.brushName("Snow Cone");
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Snow Cone Parameters:"); v.sendMessage(ChatColor.GOLD + "Snow Cone Parameters:");
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.snowcone"; return "voxelsniper.brush.snowcone";
} }
} }

Datei anzeigen

@ -1,15 +1,12 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
/** /**
@ -17,8 +14,7 @@ import org.bukkit.block.Block;
* *
* @author giltwist * @author giltwist
*/ */
public class SpiralStaircaseBrush extends Brush public class SpiralStaircaseBrush extends Brush {
{
private String stairtype = "block"; // "block" 1x1 blocks (default), "step" alternating step double step, "stair" staircase with blocks on corners private String stairtype = "block"; // "block" 1x1 blocks (default), "step" alternating step double step, "stair" staircase with blocks on corners
private String sdirect = "c"; // "c" clockwise (default), "cc" counter-clockwise private String sdirect = "c"; // "c" clockwise (default), "cc" counter-clockwise
private String sopen = "n"; // "n" north (default), "e" east, "world" south, "world" west private String sopen = "n"; // "n" north (default), "e" east, "world" south, "world" west
@ -26,16 +22,13 @@ public class SpiralStaircaseBrush extends Brush
/** /**
* *
*/ */
public SpiralStaircaseBrush() public SpiralStaircaseBrush() {
{
this.setName("Spiral Staircase"); this.setName("Spiral Staircase");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void buildStairWell(final SnipeData v, Block targetBlock) private void buildStairWell(final SnipeData v, Block targetBlock) {
{ if (v.getVoxelHeight() < 1) {
if (v.getVoxelHeight() < 1)
{
v.setVoxelHeight(1); v.setVoxelHeight(1);
v.sendMessage(ChatColor.RED + "VoxelHeight must be a natural number! Set to 1."); v.sendMessage(ChatColor.RED + "VoxelHeight must be a natural number! Set to 1.");
} }
@ -51,66 +44,44 @@ public class SpiralStaircaseBrush extends Brush
int zOffset = 0; int zOffset = 0;
int toggle = 0; int toggle = 0;
if (this.sdirect.equalsIgnoreCase("cc")) if (this.sdirect.equalsIgnoreCase("cc")) {
{ if (this.sopen.equalsIgnoreCase("n")) {
if (this.sopen.equalsIgnoreCase("n"))
{
startX = 0; startX = 0;
startZ = 2 * v.getBrushSize(); startZ = 2 * v.getBrushSize();
} } else if (this.sopen.equalsIgnoreCase("e")) {
else if (this.sopen.equalsIgnoreCase("e"))
{
startX = 0; startX = 0;
startZ = 0; startZ = 0;
} } else if (this.sopen.equalsIgnoreCase("s")) {
else if (this.sopen.equalsIgnoreCase("s"))
{
startX = 2 * v.getBrushSize(); startX = 2 * v.getBrushSize();
startZ = 0; startZ = 0;
} } else {
else
{
startX = 2 * v.getBrushSize(); startX = 2 * v.getBrushSize();
startZ = 2 * v.getBrushSize(); startZ = 2 * v.getBrushSize();
} }
} } else {
else if (this.sopen.equalsIgnoreCase("n")) {
{
if (this.sopen.equalsIgnoreCase("n"))
{
startX = 0; startX = 0;
startZ = 0; startZ = 0;
} } else if (this.sopen.equalsIgnoreCase("e")) {
else if (this.sopen.equalsIgnoreCase("e"))
{
startX = 2 * v.getBrushSize(); startX = 2 * v.getBrushSize();
startZ = 0; startZ = 0;
} } else if (this.sopen.equalsIgnoreCase("s")) {
else if (this.sopen.equalsIgnoreCase("s"))
{
startX = 2 * v.getBrushSize(); startX = 2 * v.getBrushSize();
startZ = 2 * v.getBrushSize(); startZ = 2 * v.getBrushSize();
} } else {
else
{
startX = 0; startX = 0;
startZ = 2 * v.getBrushSize(); startZ = 2 * v.getBrushSize();
} }
} }
while (y < v.getVoxelHeight()) while (y < v.getVoxelHeight()) {
{ if (this.stairtype.equalsIgnoreCase("block")) {
if (this.stairtype.equalsIgnoreCase("block"))
{
// 1x1x1 voxel material steps // 1x1x1 voxel material steps
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
y++; y++;
} } else if (this.stairtype.equalsIgnoreCase("step")) {
else if (this.stairtype.equalsIgnoreCase("step"))
{
// alternating step-doublestep, uses data value to determine type // alternating step-doublestep, uses data value to determine type
switch (toggle) switch (toggle) {
{
case 0: case 0:
toggle = 2; toggle = 2;
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
@ -131,150 +102,97 @@ public class SpiralStaircaseBrush extends Brush
} }
// Adjust horizontal position and do stair-option array stuff // Adjust horizontal position and do stair-option array stuff
if (startX + xOffset == 0) if (startX + xOffset == 0) { // All North
{ // All North if (startZ + zOffset == 0) { // NORTHEAST
if (startZ + zOffset == 0) if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{ // NORTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
} }
if (this.sdirect.equalsIgnoreCase("c")) if (this.sdirect.equalsIgnoreCase("c")) {
{
xOffset++; xOffset++;
} } else {
else
{
zOffset++; zOffset++;
} }
} } else if (startZ + zOffset == 2 * v.getBrushSize()) { // NORTHWEST
else if (startZ + zOffset == 2 * v.getBrushSize()) if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{ // NORTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
} }
if (this.sdirect.equalsIgnoreCase("c")) if (this.sdirect.equalsIgnoreCase("c")) {
{
zOffset--; zOffset--;
} } else {
else
{
xOffset++; xOffset++;
} }
} } else { // JUST PLAIN NORTH
else if (this.sdirect.equalsIgnoreCase("c")) {
{ // JUST PLAIN NORTH if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 5; spiral[startX + xOffset][y][startZ + zOffset] = 5;
y++; y++;
} }
zOffset--; zOffset--;
} } else {
else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 4; spiral[startX + xOffset][y][startZ + zOffset] = 4;
y++; y++;
} }
zOffset++; zOffset++;
} }
} }
} } else if (startX + xOffset == 2 * v.getBrushSize()) { // ALL SOUTH
else if (startX + xOffset == 2 * v.getBrushSize()) if (startZ + zOffset == 0) { // SOUTHEAST
{ // ALL SOUTH if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
if (startZ + zOffset == 0)
{ // SOUTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
} }
if (this.sdirect.equalsIgnoreCase("c")) if (this.sdirect.equalsIgnoreCase("c")) {
{
zOffset++; zOffset++;
} } else {
else
{
xOffset--; xOffset--;
} }
} } else if (startZ + zOffset == 2 * v.getBrushSize()) { // SOUTHWEST
else if (startZ + zOffset == 2 * v.getBrushSize()) if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{ // SOUTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
} }
if (this.sdirect.equalsIgnoreCase("c")) if (this.sdirect.equalsIgnoreCase("c")) {
{
xOffset--; xOffset--;
} } else {
else
{
zOffset--; zOffset--;
} }
} } else { // JUST PLAIN SOUTH
else if (this.sdirect.equalsIgnoreCase("c")) {
{ // JUST PLAIN SOUTH if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 4; spiral[startX + xOffset][y][startZ + zOffset] = 4;
y++; y++;
} }
zOffset++; zOffset++;
} } else {
else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 5; spiral[startX + xOffset][y][startZ + zOffset] = 5;
y++; y++;
} }
zOffset--; zOffset--;
} }
} }
} } else if (startZ + zOffset == 0) { // JUST PLAIN EAST
else if (startZ + zOffset == 0) if (this.sdirect.equalsIgnoreCase("c")) {
{ // JUST PLAIN EAST if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 2; spiral[startX + xOffset][y][startZ + zOffset] = 2;
y++; y++;
} }
xOffset++; xOffset++;
} } else {
else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 3; spiral[startX + xOffset][y][startZ + zOffset] = 3;
y++; y++;
} }
xOffset--; xOffset--;
} }
} } else { // JUST PLAIN WEST
else if (this.sdirect.equalsIgnoreCase("c")) {
{ // JUST PLAIN WEST if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 3; spiral[startX + xOffset][y][startZ + zOffset] = 3;
y++; y++;
} }
xOffset--; xOffset--;
} } else {
else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 2; spiral[startX + xOffset][y][startZ + zOffset] = 2;
y++; y++;
} }
@ -286,28 +204,20 @@ public class SpiralStaircaseBrush extends Brush
final Undo undo = new Undo(); final Undo undo = new Undo();
// Make the changes // Make the changes
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int i = v.getVoxelHeight() - 1; i >= 0; i--) {
for (int i = v.getVoxelHeight() - 1; i >= 0; i--) for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
{
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
int blockPositionX = targetBlock.getX(); int blockPositionX = targetBlock.getX();
int blockPositionY = targetBlock.getY(); int blockPositionY = targetBlock.getY();
int blockPositionZ = targetBlock.getZ(); int blockPositionZ = targetBlock.getZ();
switch (spiral[x][i][z]) switch (spiral[x][i][z]) {
{
case 0: case 0:
if (i != v.getVoxelHeight() - 1) if (i != v.getVoxelHeight() - 1) {
{ if (!((this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) && spiral[x][i + 1][z] == 1)) {
if (!((this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) && spiral[x][i + 1][z] == 1))
{
this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i, BlockTypes.AIR.getInternalId()); this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i, BlockTypes.AIR.getInternalId());
} }
} } else {
else
{
this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i, BlockTypes.AIR.getInternalId()); this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i, BlockTypes.AIR.getInternalId());
} }
@ -316,41 +226,28 @@ public class SpiralStaircaseBrush extends Brush
switch (stairtype) { switch (stairtype) {
} }
if (this.stairtype.equalsIgnoreCase("block")) if (this.stairtype.equalsIgnoreCase("block")) {
{
this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i, v.getVoxelId()); this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i, v.getVoxelId());
} } else if (this.stairtype.equalsIgnoreCase("step")) {
else if (this.stairtype.equalsIgnoreCase("step"))
{
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 44, v.getPropertyId()); this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 44, v.getPropertyId());
} } else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i - 1, v.getVoxelId()); this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY + i - 1, v.getVoxelId());
} }
break; break;
case 2: case 2:
if (this.stairtype.equalsIgnoreCase("step")) if (this.stairtype.equalsIgnoreCase("step")) {
{
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 43, v.getPropertyId()); this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 43, v.getPropertyId());
} } else if (this.stairtype.equalsIgnoreCase("woodstair")) {
else if (this.stairtype.equalsIgnoreCase("woodstair")) this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 53, 0);
{ } else if (this.stairtype.equalsIgnoreCase("cobblestair")) {
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 53, 0); this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 67, 0);
}
else if (this.stairtype.equalsIgnoreCase("cobblestair"))
{
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 67, 0);
} }
break; break;
default: default:
if (this.stairtype.equalsIgnoreCase("woodstair")) if (this.stairtype.equalsIgnoreCase("woodstair")) {
{
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 53, (spiral[x][i][z] - 2)); this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 53, (spiral[x][i][z] - 2));
} } else if (this.stairtype.equalsIgnoreCase("cobblestair")) {
else if (this.stairtype.equalsIgnoreCase("cobblestair"))
{
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 67, (spiral[x][i][z] - 2)); this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY + i, blockPositionZ - v.getBrushSize() + z, 67, (spiral[x][i][z] - 2));
} }
break; break;
@ -362,10 +259,8 @@ public class SpiralStaircaseBrush extends Brush
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void digStairWell(final SnipeData v, Block targetBlock) private void digStairWell(final SnipeData v, Block targetBlock) {
{ if (v.getVoxelHeight() < 1) {
if (v.getVoxelHeight() < 1)
{
v.setVoxelHeight(1); v.setVoxelHeight(1);
v.sendMessage(ChatColor.RED + "VoxelHeight must be a natural number! Set to 1."); v.sendMessage(ChatColor.RED + "VoxelHeight must be a natural number! Set to 1.");
} }
@ -382,66 +277,44 @@ public class SpiralStaircaseBrush extends Brush
int zOffset = 0; int zOffset = 0;
int toggle = 0; int toggle = 0;
if (this.sdirect.equalsIgnoreCase("cc")) if (this.sdirect.equalsIgnoreCase("cc")) {
{ if (this.sopen.equalsIgnoreCase("n")) {
if (this.sopen.equalsIgnoreCase("n"))
{
startX = 0; startX = 0;
startZ = 2 * v.getBrushSize(); startZ = 2 * v.getBrushSize();
} } else if (this.sopen.equalsIgnoreCase("e")) {
else if (this.sopen.equalsIgnoreCase("e"))
{
startX = 0; startX = 0;
startZ = 0; startZ = 0;
} } else if (this.sopen.equalsIgnoreCase("s")) {
else if (this.sopen.equalsIgnoreCase("s"))
{
startX = 2 * v.getBrushSize(); startX = 2 * v.getBrushSize();
startZ = 0; startZ = 0;
} } else {
else
{
startX = 2 * v.getBrushSize(); startX = 2 * v.getBrushSize();
startZ = 2 * v.getBrushSize(); startZ = 2 * v.getBrushSize();
} }
} } else {
else if (this.sopen.equalsIgnoreCase("n")) {
{
if (this.sopen.equalsIgnoreCase("n"))
{
startX = 0; startX = 0;
startZ = 0; startZ = 0;
} } else if (this.sopen.equalsIgnoreCase("e")) {
else if (this.sopen.equalsIgnoreCase("e"))
{
startX = 2 * v.getBrushSize(); startX = 2 * v.getBrushSize();
startZ = 0; startZ = 0;
} } else if (this.sopen.equalsIgnoreCase("s")) {
else if (this.sopen.equalsIgnoreCase("s"))
{
startX = 2 * v.getBrushSize(); startX = 2 * v.getBrushSize();
startZ = 2 * v.getBrushSize(); startZ = 2 * v.getBrushSize();
} } else {
else
{
startX = 0; startX = 0;
startZ = 2 * v.getBrushSize(); startZ = 2 * v.getBrushSize();
} }
} }
while (y < v.getVoxelHeight()) while (y < v.getVoxelHeight()) {
{ if (this.stairtype.equalsIgnoreCase("block")) {
if (this.stairtype.equalsIgnoreCase("block"))
{
// 1x1x1 voxel material steps // 1x1x1 voxel material steps
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
y++; y++;
} } else if (this.stairtype.equalsIgnoreCase("step")) {
else if (this.stairtype.equalsIgnoreCase("step"))
{
// alternating step-doublestep, uses data value to determine type // alternating step-doublestep, uses data value to determine type
switch (toggle) switch (toggle) {
{
case 0: case 0:
toggle = 2; toggle = 2;
spiral[startX + xOffset][y][startZ + zOffset] = 2; spiral[startX + xOffset][y][startZ + zOffset] = 2;
@ -462,53 +335,34 @@ public class SpiralStaircaseBrush extends Brush
} }
// Adjust horizontal position and do stair-option array stuff // Adjust horizontal position and do stair-option array stuff
if (startX + xOffset == 0) if (startX + xOffset == 0) { // All North
{ // All North if (startZ + zOffset == 0) { // NORTHEAST
if (startZ + zOffset == 0) if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{ // NORTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
} }
if (this.sdirect.equalsIgnoreCase("c")) if (this.sdirect.equalsIgnoreCase("c")) {
{
xOffset++; xOffset++;
} } else {
else
{
zOffset++; zOffset++;
} }
} } else if (startZ + zOffset == 2 * v.getBrushSize()) { // NORTHWEST
else if (startZ + zOffset == 2 * v.getBrushSize()) if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{ // NORTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
} }
if (this.sdirect.equalsIgnoreCase("c")) if (this.sdirect.equalsIgnoreCase("c")) {
{
zOffset--; zOffset--;
} } else {
else
{
xOffset++; xOffset++;
} }
} } else { // JUST PLAIN NORTH
else if (this.sdirect.equalsIgnoreCase("c")) {
{ // JUST PLAIN NORTH if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 4; spiral[startX + xOffset][y][startZ + zOffset] = 4;
y++; y++;
} }
zOffset--; zOffset--;
} } else {
else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 5; spiral[startX + xOffset][y][startZ + zOffset] = 5;
y++; y++;
} }
@ -516,54 +370,34 @@ public class SpiralStaircaseBrush extends Brush
} }
} }
} } else if (startX + xOffset == 2 * v.getBrushSize()) { // ALL SOUTH
else if (startX + xOffset == 2 * v.getBrushSize()) if (startZ + zOffset == 0) { // SOUTHEAST
{ // ALL SOUTH if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
if (startZ + zOffset == 0)
{ // SOUTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
} }
if (this.sdirect.equalsIgnoreCase("c")) if (this.sdirect.equalsIgnoreCase("c")) {
{
zOffset++; zOffset++;
} } else {
else
{
xOffset--; xOffset--;
} }
} } else if (startZ + zOffset == 2 * v.getBrushSize()) { // SOUTHWEST
else if (startZ + zOffset == 2 * v.getBrushSize()) if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{ // SOUTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 1; spiral[startX + xOffset][y][startZ + zOffset] = 1;
} }
if (this.sdirect.equalsIgnoreCase("c")) if (this.sdirect.equalsIgnoreCase("c")) {
{
xOffset--; xOffset--;
} } else {
else
{
zOffset--; zOffset--;
} }
} } else { // JUST PLAIN SOUTH
else if (this.sdirect.equalsIgnoreCase("c")) {
{ // JUST PLAIN SOUTH if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 5; spiral[startX + xOffset][y][startZ + zOffset] = 5;
y++; y++;
} }
zOffset++; zOffset++;
} } else {
else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 4; spiral[startX + xOffset][y][startZ + zOffset] = 4;
y++; y++;
} }
@ -571,43 +405,29 @@ public class SpiralStaircaseBrush extends Brush
} }
} }
} } else if (startZ + zOffset == 0) { // JUST PLAIN EAST
else if (startZ + zOffset == 0) if (this.sdirect.equalsIgnoreCase("c")) {
{ // JUST PLAIN EAST if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 3; spiral[startX + xOffset][y][startZ + zOffset] = 3;
y++; y++;
} }
xOffset++; xOffset++;
} } else {
else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 2; spiral[startX + xOffset][y][startZ + zOffset] = 2;
y++; y++;
} }
xOffset--; xOffset--;
} }
} } else { // JUST PLAIN WEST
else if (this.sdirect.equalsIgnoreCase("c")) {
{ // JUST PLAIN WEST if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 2; spiral[startX + xOffset][y][startZ + zOffset] = 2;
y++; y++;
} }
xOffset--; xOffset--;
} } else {
else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
spiral[startX + xOffset][y][startZ + zOffset] = 3; spiral[startX + xOffset][y][startZ + zOffset] = 3;
y++; y++;
} }
@ -620,58 +440,41 @@ public class SpiralStaircaseBrush extends Brush
final Undo undo = new Undo(); final Undo undo = new Undo();
// Make the changes // Make the changes
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{
for (int i = v.getVoxelHeight() - 1; i >= 0; i--) for (int i = v.getVoxelHeight() - 1; i >= 0; i--) {
{
for (int z = 2 * v.getBrushSize(); z >= 0; z--) for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
{
int blockPositionX = targetBlock.getX(); int blockPositionX = targetBlock.getX();
int blockPositionY = targetBlock.getY(); int blockPositionY = targetBlock.getY();
int blockPositionZ = targetBlock.getZ(); int blockPositionZ = targetBlock.getZ();
switch (spiral[x][i][z]) switch (spiral[x][i][z]) {
{
case 0: case 0:
this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, BlockTypes.AIR.getInternalId()); this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, BlockTypes.AIR.getInternalId());
break; break;
case 1: case 1:
if (this.stairtype.equalsIgnoreCase("block")) if (this.stairtype.equalsIgnoreCase("block")) {
{
this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, v.getVoxelId()); this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, v.getVoxelId());
} } else if (this.stairtype.equalsIgnoreCase("step")) {
else if (this.stairtype.equalsIgnoreCase("step"))
{
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 44, v.getPropertyId()); this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 44, v.getPropertyId());
} } else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
else if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, v.getVoxelId()); this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, v.getVoxelId());
} }
break; break;
case 2: case 2:
if (this.stairtype.equalsIgnoreCase("step")) if (this.stairtype.equalsIgnoreCase("step")) {
{
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 43, v.getPropertyId()); this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 43, v.getPropertyId());
} } else if (this.stairtype.equalsIgnoreCase("woodstair")) {
else if (this.stairtype.equalsIgnoreCase("woodstair")) this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 53, 0);
{ } else if (this.stairtype.equalsIgnoreCase("cobblestair")) {
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 53, 0);
}
else if (this.stairtype.equalsIgnoreCase("cobblestair"))
{
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 67, 0); this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 67, 0);
} }
break; break;
default: default:
if (this.stairtype.equalsIgnoreCase("woodstair")) if (this.stairtype.equalsIgnoreCase("woodstair")) {
{
this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 53, (spiral[x][i][z] - 2)); this.setBlockLegacy(blockPositionX - v.getBrushSize() + x, blockPositionY - i, blockPositionZ - v.getBrushSize() + z, 53, (spiral[x][i][z] - 2));
} } else if (this.stairtype.equalsIgnoreCase("cobblestair")) {
else if (this.stairtype.equalsIgnoreCase("cobblestair"))
{
this.setBlockLegacy(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, 67, (spiral[x][i][z] - 2)); this.setBlockLegacy(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, 67, (spiral[x][i][z] - 2));
} }
break; break;
@ -683,20 +486,17 @@ public class SpiralStaircaseBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.digStairWell(v, this.getTargetBlock()); // make stairwell below target this.digStairWell(v, this.getTargetBlock()); // make stairwell below target
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.buildStairWell(v, this.getLastBlock()); // make stairwell above target this.buildStairWell(v, this.getLastBlock()); // make stairwell above target
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName("Spiral Staircase"); vm.brushName("Spiral Staircase");
vm.size(); vm.size();
vm.voxel(); vm.voxel();
@ -708,10 +508,8 @@ public class SpiralStaircaseBrush extends Brush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Spiral Staircase Parameters:"); v.sendMessage(ChatColor.GOLD + "Spiral Staircase Parameters:");
v.sendMessage(ChatColor.AQUA + "/b sstair 'block' (default) | step' | 'woodstair' | 'cobblestair' -- set the type of staircase"); v.sendMessage(ChatColor.AQUA + "/b sstair 'block' (default) | step' | 'woodstair' | 'cobblestair' -- set the type of staircase");
v.sendMessage(ChatColor.AQUA + "/b sstair 'c' (default) | 'cc' -- set the turning direction of staircase"); v.sendMessage(ChatColor.AQUA + "/b sstair 'c' (default) | 'cc' -- set the turning direction of staircase");
@ -719,8 +517,7 @@ public class SpiralStaircaseBrush extends Brush
return; return;
} }
for (int i = 1; i < par.length; i++) for (int i = 1; i < par.length; i++) {
{
// stairs // stairs
// step/slab // step/slab
@ -729,34 +526,27 @@ public class SpiralStaircaseBrush extends Brush
this.stairtype = par[i].toLowerCase().intern(); this.stairtype = par[i].toLowerCase().intern();
v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype); v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype);
return; return;
} catch (InputParseException ignore) {} } catch (InputParseException ignore) {
}
if ("block".equals(par[i].toLowerCase())) { if ("block".equals(par[i].toLowerCase())) {
} }
if (par[i].equalsIgnoreCase("block") || par[i].equalsIgnoreCase("step") || par[i].equalsIgnoreCase("woodstair") || par[i].equalsIgnoreCase("cobblestair")) if (par[i].equalsIgnoreCase("block") || par[i].equalsIgnoreCase("step") || par[i].equalsIgnoreCase("woodstair") || par[i].equalsIgnoreCase("cobblestair")) {
{
this.stairtype = par[i].toLowerCase().intern(); this.stairtype = par[i].toLowerCase().intern();
v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype); v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype);
} } else if (par[i].equalsIgnoreCase("c") || par[i].equalsIgnoreCase("cc")) {
else if (par[i].equalsIgnoreCase("c") || par[i].equalsIgnoreCase("cc"))
{
this.sdirect = par[i]; this.sdirect = par[i];
v.sendMessage(ChatColor.BLUE + "Staircase turns: " + this.sdirect); v.sendMessage(ChatColor.BLUE + "Staircase turns: " + this.sdirect);
} } else if (par[i].equalsIgnoreCase("n") || par[i].equalsIgnoreCase("e") || par[i].equalsIgnoreCase("s") || par[i].equalsIgnoreCase("world")) {
else if (par[i].equalsIgnoreCase("n") || par[i].equalsIgnoreCase("e") || par[i].equalsIgnoreCase("s") || par[i].equalsIgnoreCase("world"))
{
this.sopen = par[i]; this.sopen = par[i];
v.sendMessage(ChatColor.BLUE + "Staircase opens: " + this.sopen); v.sendMessage(ChatColor.BLUE + "Staircase opens: " + this.sopen);
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.spiralstaircase"; return "voxelsniper.brush.spiralstaircase";
} }
} }

Datei anzeigen

@ -5,7 +5,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import java.util.Random; import java.util.Random;
@ -14,8 +13,7 @@ import java.util.Random;
* *
* @author Voxel * @author Voxel
*/ */
public class SplatterBallBrush extends PerformBrush public class SplatterBallBrush extends PerformBrush {
{
private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_MIN = 1;
private static final int GROW_PERCENT_DEFAULT = 1000; private static final int GROW_PERCENT_DEFAULT = 1000;
private static final int GROW_PERCENT_MAX = 9999; private static final int GROW_PERCENT_MAX = 9999;
@ -33,25 +31,20 @@ public class SplatterBallBrush extends PerformBrush
/** /**
* *
*/ */
public SplatterBallBrush() public SplatterBallBrush() {
{
this.setName("Splatter Ball"); this.setName("Splatter Ball");
} }
private void splatterBall(final SnipeData v, AsyncBlock targetBlock) private void splatterBall(final SnipeData v, AsyncBlock targetBlock) {
{ if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Seed percent set to: 10%"); v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Seed percent set to: 10%");
this.seedPercent = SEED_PERCENT_DEFAULT; this.seedPercent = SEED_PERCENT_DEFAULT;
} }
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
{
v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Growth percent set to: 10%"); v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Growth percent set to: 10%");
this.growPercent = GROW_PERCENT_DEFAULT; this.growPercent = GROW_PERCENT_DEFAULT;
} }
if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) {
{
v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Recursions set to: 3"); v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Recursions set to: 3");
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
} }
@ -59,14 +52,10 @@ public class SplatterBallBrush extends PerformBrush
final int[][][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array // Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
{ if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) {
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent)
{
splat[x][y][z] = 1; splat[x][y][z] = 1;
} }
} }
@ -77,48 +66,36 @@ public class SplatterBallBrush extends PerformBrush
final int[][][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
int growcheck; int growcheck;
for (int r = 0; r < this.splatterRecursions; r++) for (int r = 0; r < this.splatterRecursions; r++) {
{
this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); this.growPercent = gref - ((gref / this.splatterRecursions) * (r));
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
{
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
tempSplat[x][y][z] = splat[x][y][z]; // prime tempsplat tempSplat[x][y][z] = splat[x][y][z]; // prime tempsplat
growcheck = 0; growcheck = 0;
if (splat[x][y][z] == 0) if (splat[x][y][z] == 0) {
{ if (x != 0 && splat[x - 1][y][z] == 1) {
if (x != 0 && splat[x - 1][y][z] == 1)
{
growcheck++; growcheck++;
} }
if (y != 0 && splat[x][y - 1][z] == 1) if (y != 0 && splat[x][y - 1][z] == 1) {
{
growcheck++; growcheck++;
} }
if (z != 0 && splat[x][y][z - 1] == 1) if (z != 0 && splat[x][y][z - 1] == 1) {
{
growcheck++; growcheck++;
} }
if (x != 2 * v.getBrushSize() && splat[x + 1][y][z] == 1) if (x != 2 * v.getBrushSize() && splat[x + 1][y][z] == 1) {
{
growcheck++; growcheck++;
} }
if (y != 2 * v.getBrushSize() && splat[x][y + 1][z] == 1) if (y != 2 * v.getBrushSize() && splat[x][y + 1][z] == 1) {
{
growcheck++; growcheck++;
} }
if (z != 2 * v.getBrushSize() && splat[x][y][z + 1] == 1) if (z != 2 * v.getBrushSize() && splat[x][y][z + 1] == 1) {
{
growcheck++; growcheck++;
} }
} }
if (growcheck >= GROW_PERCENT_MIN && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) if (growcheck >= GROW_PERCENT_MIN && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) {
{
tempSplat[x][y][z] = 1; // prevent bleed into splat tempSplat[x][y][z] = 1; // prevent bleed into splat
} }
@ -126,26 +103,20 @@ public class SplatterBallBrush extends PerformBrush
} }
} }
// integrate tempsplat back into splat at end of iteration // integrate tempsplat back into splat at end of iteration
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
if (2 * v.getBrushSize() + 1 >= 0) if (2 * v.getBrushSize() + 1 >= 0)
System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0,
2 * v.getBrushSize() + 1); 2 * v.getBrushSize() + 1);
} }
} }
} }
this.growPercent = gref; this.growPercent = gref;
// Fill 1x1x1 holes // Fill 1x1x1 holes
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
{ if (splat[Math.max(x - 1, 0)][y][z] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y][z] == 1 && splat[x][Math.max(0, y - 1)][z] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)][z] == 1) {
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
if (splat[Math.max(x - 1, 0)][y][z] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y][z] == 1 && splat[x][Math.max(0, y - 1)][z] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)][z] == 1)
{
splat[x][y][z] = 1; splat[x][y][z] = 1;
} }
} }
@ -155,18 +126,14 @@ public class SplatterBallBrush extends PerformBrush
// Make the changes // Make the changes
final double rSquared = Math.pow(v.getBrushSize() + 1, 2); final double rSquared = Math.pow(v.getBrushSize() + 1, 2);
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{
final double xSquared = Math.pow(x - v.getBrushSize() - 1, 2); final double xSquared = Math.pow(x - v.getBrushSize() - 1, 2);
for (int y = 2 * v.getBrushSize(); y >= 0; y--) for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
{
final double ySquared = Math.pow(y - v.getBrushSize() - 1, 2); final double ySquared = Math.pow(y - v.getBrushSize() - 1, 2);
for (int z = 2 * v.getBrushSize(); z >= 0; z--) for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
{ if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - v.getBrushSize() - 1, 2) <= rSquared) {
if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - v.getBrushSize() - 1, 2) <= rSquared)
{
current.perform(targetBlock.getRelative(-v.getBrushSize() + x, -v.getBrushSize() + y, -v.getBrushSize() + z)); current.perform(targetBlock.getRelative(-v.getBrushSize() + x, -v.getBrushSize() + y, -v.getBrushSize() + z));
} }
} }
@ -177,30 +144,24 @@ public class SplatterBallBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.splatterBall(v, this.getTargetBlock()); this.splatterBall(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.splatterBall(v, this.getLastBlock()); this.splatterBall(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{ if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
this.seedPercent = SEED_PERCENT_DEFAULT; this.seedPercent = SEED_PERCENT_DEFAULT;
} }
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
{
this.growPercent = GROW_PERCENT_DEFAULT; this.growPercent = GROW_PERCENT_DEFAULT;
} }
if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) {
{
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
} }
vm.brushName("Splatter Ball"); vm.brushName("Splatter Ball");
@ -212,72 +173,51 @@ public class SplatterBallBrush extends PerformBrush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Splatter Ball brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Splatter Ball brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b sb s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000"); v.sendMessage(ChatColor.AQUA + "/b sb s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000");
v.sendMessage(ChatColor.AQUA + "/b sb g[int] -- set a growth percentage (1-9999). Default is 1000"); v.sendMessage(ChatColor.AQUA + "/b sb g[int] -- set a growth percentage (1-9999). Default is 1000");
v.sendMessage(ChatColor.AQUA + "/b sb r[int] -- set a recursion (1-10). Default is 3"); v.sendMessage(ChatColor.AQUA + "/b sb r[int] -- set a recursion (1-10). Default is 3");
return; return;
} } else if (parameter.startsWith("s")) {
else if (parameter.startsWith("s"))
{
final double temp = Integer.parseInt(parameter.replace("s", "")); final double temp = Integer.parseInt(parameter.replace("s", ""));
if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%");
this.seedPercent = (int) temp; this.seedPercent = (int) temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!"); v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!");
} }
} } else if (parameter.startsWith("g")) {
else if (parameter.startsWith("g"))
{
final double temp = Integer.parseInt(parameter.replace("g", "")); final double temp = Integer.parseInt(parameter.replace("g", ""));
if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%");
this.growPercent = (int) temp; this.growPercent = (int) temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!"); v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!");
} }
} } else if (parameter.startsWith("r")) {
else if (parameter.startsWith("r"))
{
final int temp = Integer.parseInt(parameter.replace("r", "")); final int temp = Integer.parseInt(parameter.replace("r", ""));
if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp); v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp);
this.splatterRecursions = temp; this.splatterRecursions = temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!");
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.splatterball"; return "voxelsniper.brush.splatterball";
} }
} }

Datei anzeigen

@ -5,7 +5,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import java.util.Random; import java.util.Random;
@ -14,8 +13,7 @@ import java.util.Random;
* *
* @author Voxel * @author Voxel
*/ */
public class SplatterDiscBrush extends PerformBrush public class SplatterDiscBrush extends PerformBrush {
{
private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_MIN = 1;
private static final int GROW_PERCENT_DEFAULT = 1000; private static final int GROW_PERCENT_DEFAULT = 1000;
private static final int GROW_PERCENT_MAX = 9999; private static final int GROW_PERCENT_MAX = 9999;
@ -33,38 +31,30 @@ public class SplatterDiscBrush extends PerformBrush
/** /**
* *
*/ */
public SplatterDiscBrush() public SplatterDiscBrush() {
{
this.setName("Splatter Disc"); this.setName("Splatter Disc");
} }
private void splatterDisc(final SnipeData v, AsyncBlock targetBlock) private void splatterDisc(final SnipeData v, AsyncBlock targetBlock) {
{ if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%"); v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%");
this.seedPercent = SEED_PERCENT_DEFAULT; this.seedPercent = SEED_PERCENT_DEFAULT;
} }
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
{
v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%"); v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%");
this.growPercent = GROW_PERCENT_DEFAULT; this.growPercent = GROW_PERCENT_DEFAULT;
} }
if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) {
{
v.sendMessage(ChatColor.BLUE + "Recursions set to: 3"); v.sendMessage(ChatColor.BLUE + "Recursions set to: 3");
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
} }
final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array // Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) {
{
splat[x][y] = 1; splat[x][y] = 1;
} }
@ -74,59 +64,46 @@ public class SplatterDiscBrush extends PerformBrush
final int gref = this.growPercent; final int gref = this.growPercent;
int growcheck; int growcheck;
final int[][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
for (int r = 0; r < this.splatterRecursions; r++) for (int r = 0; r < this.splatterRecursions; r++) {
{
this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); this.growPercent = gref - ((gref / this.splatterRecursions) * (r));
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
tempSplat[x][y] = splat[x][y]; // prime tempsplat tempSplat[x][y] = splat[x][y]; // prime tempsplat
growcheck = 0; growcheck = 0;
if (splat[x][y] == 0) if (splat[x][y] == 0) {
{ if (x != 0 && splat[x - 1][y] == 1) {
if (x != 0 && splat[x - 1][y] == 1)
{
growcheck++; growcheck++;
} }
if (y != 0 && splat[x][y - 1] == 1) if (y != 0 && splat[x][y - 1] == 1) {
{
growcheck++; growcheck++;
} }
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) {
{
growcheck++; growcheck++;
} }
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) {
{
growcheck++; growcheck++;
} }
} }
if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) {
{
tempSplat[x][y] = 1; // prevent bleed into splat tempSplat[x][y] = 1; // prevent bleed into splat
} }
} }
} }
// integrate tempsplat back into splat at end of iteration // integrate tempsplat back into splat at end of iteration
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{
if (2 * v.getBrushSize() + 1 >= 0) if (2 * v.getBrushSize() + 1 >= 0)
System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1);
} }
} }
this.growPercent = gref; this.growPercent = gref;
// Fill 1x1 holes // Fill 1x1 holes
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) if (splat[Math.max(x - 1, 0)][y] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y] == 1 && splat[x][Math.max(0, y - 1)] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)] == 1) {
{
if (splat[Math.max(x - 1, 0)][y] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y] == 1 && splat[x][Math.max(0, y - 1)] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)] == 1)
{
splat[x][y] = 1; splat[x][y] = 1;
} }
} }
@ -134,13 +111,10 @@ public class SplatterDiscBrush extends PerformBrush
// Make the changes // Make the changes
final double rSquared = Math.pow(v.getBrushSize() + 1, 2); final double rSquared = Math.pow(v.getBrushSize() + 1, 2);
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{
final double xSquared = Math.pow(x - v.getBrushSize() - 1, 2); final double xSquared = Math.pow(x - v.getBrushSize() - 1, 2);
for (int y = 2 * v.getBrushSize(); y >= 0; y--) for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
{ if (splat[x][y] == 1 && xSquared + Math.pow(y - v.getBrushSize() - 1, 2) <= rSquared) {
if (splat[x][y] == 1 && xSquared + Math.pow(y - v.getBrushSize() - 1, 2) <= rSquared)
{
current.perform(targetBlock.getRelative(x - v.getBrushSize(), 0, y - v.getBrushSize())); current.perform(targetBlock.getRelative(x - v.getBrushSize(), 0, y - v.getBrushSize()));
} }
} }
@ -149,30 +123,24 @@ public class SplatterDiscBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.splatterDisc(v, this.getTargetBlock()); this.splatterDisc(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.splatterDisc(v, this.getLastBlock()); this.splatterDisc(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{ if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
this.seedPercent = SEED_PERCENT_DEFAULT; this.seedPercent = SEED_PERCENT_DEFAULT;
} }
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
{
this.growPercent = GROW_PERCENT_DEFAULT; this.growPercent = GROW_PERCENT_DEFAULT;
} }
if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) {
{
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
} }
vm.brushName("Splatter Disc"); vm.brushName("Splatter Disc");
@ -183,69 +151,48 @@ public class SplatterDiscBrush extends PerformBrush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Splatter Disc brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Splatter Disc brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b sd s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000"); v.sendMessage(ChatColor.AQUA + "/b sd s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000");
v.sendMessage(ChatColor.AQUA + "/b sd g[int] -- set a growth percentage (1-9999). Default is 1000"); v.sendMessage(ChatColor.AQUA + "/b sd g[int] -- set a growth percentage (1-9999). Default is 1000");
v.sendMessage(ChatColor.AQUA + "/b sd r[int] -- set a recursion (1-10). Default is 3"); v.sendMessage(ChatColor.AQUA + "/b sd r[int] -- set a recursion (1-10). Default is 3");
return; return;
} } else if (parameter.startsWith("s")) {
else if (parameter.startsWith("s"))
{
final double temp = Integer.parseInt(parameter.replace("s", "")); final double temp = Integer.parseInt(parameter.replace("s", ""));
if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%");
this.seedPercent = (int) temp; this.seedPercent = (int) temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!"); v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!");
} }
} } else if (parameter.startsWith("g")) {
else if (parameter.startsWith("g"))
{
final double temp = Integer.parseInt(parameter.replace("g", "")); final double temp = Integer.parseInt(parameter.replace("g", ""));
if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%");
this.growPercent = (int) temp; this.growPercent = (int) temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!"); v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!");
} }
} } else if (parameter.startsWith("r")) {
else if (parameter.startsWith("r"))
{
final int temp = Integer.parseInt(parameter.replace("r", "")); final int temp = Integer.parseInt(parameter.replace("r", ""));
if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp); v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp);
this.splatterRecursions = temp; this.splatterRecursions = temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!");
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.splatterdisc"; return "voxelsniper.brush.splatterdisc";
} }
} }

Datei anzeigen

@ -15,8 +15,7 @@ import java.util.Random;
* *
* @author Gavjenks Splatterized blockPositionY Giltwist * @author Gavjenks Splatterized blockPositionY Giltwist
*/ */
public class SplatterOverlayBrush extends PerformBrush public class SplatterOverlayBrush extends PerformBrush {
{
private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_MIN = 1;
private static final int GROW_PERCENT_DEFAULT = 1000; private static final int GROW_PERCENT_DEFAULT = 1000;
private static final int GROW_PERCENT_MAX = 9999; private static final int GROW_PERCENT_MAX = 9999;
@ -38,24 +37,19 @@ public class SplatterOverlayBrush extends PerformBrush
/** /**
* *
*/ */
public SplatterOverlayBrush() public SplatterOverlayBrush() {
{
this.setName("Splatter Overlay"); this.setName("Splatter Overlay");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void sOverlay(final SnipeData v) private void sOverlay(final SnipeData v) {
{
// Splatter Time // Splatter Time
final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array // Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) {
{
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent)
{
splat[x][y] = 1; splat[x][y] = 1;
} }
} }
@ -65,45 +59,35 @@ public class SplatterOverlayBrush extends PerformBrush
final int[][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
int growcheck; int growcheck;
for (int r = 0; r < this.splatterRecursions; r++) for (int r = 0; r < this.splatterRecursions; r++) {
{
this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); this.growPercent = gref - ((gref / this.splatterRecursions) * (r));
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
tempSplat[x][y] = splat[x][y]; // prime tempsplat tempSplat[x][y] = splat[x][y]; // prime tempsplat
growcheck = 0; growcheck = 0;
if (splat[x][y] == 0) if (splat[x][y] == 0) {
{ if (x != 0 && splat[x - 1][y] == 1) {
if (x != 0 && splat[x - 1][y] == 1)
{
growcheck++; growcheck++;
} }
if (y != 0 && splat[x][y - 1] == 1) if (y != 0 && splat[x][y - 1] == 1) {
{
growcheck++; growcheck++;
} }
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) {
{
growcheck++; growcheck++;
} }
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) {
{
growcheck++; growcheck++;
} }
} }
if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) {
{
tempSplat[x][y] = 1; // prevent bleed into splat tempSplat[x][y] = 1; // prevent bleed into splat
} }
} }
} }
// integrate tempsplat back into splat at end of iteration // integrate tempsplat back into splat at end of iteration
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{
if (2 * v.getBrushSize() + 1 >= 0) if (2 * v.getBrushSize() + 1 >= 0)
System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1);
} }
@ -113,26 +97,19 @@ public class SplatterOverlayBrush extends PerformBrush
final int[][] memory = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][] memory = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2); final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2);
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
{ for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) for (int y = this.getTargetBlock().getY(); y > 0; y--) {
{
for (int y = this.getTargetBlock().getY(); y > 0; y--)
{
// start scanning from the height you clicked at // start scanning from the height you clicked at
if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1) if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1) {
{
// if haven't already found the surface in this column // if haven't already found the surface in this column
if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared && splat[x + v.getBrushSize()][z + v.getBrushSize()] == 1) if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared && splat[x + v.getBrushSize()][z + v.getBrushSize()] == 1) {
{
// if inside of the column && if to be splattered // if inside of the column && if to be splattered
final int check = this.getBlockIdAt(this.getTargetBlock().getX() + x, y + 1, this.getTargetBlock().getZ() + z); final int check = this.getBlockIdAt(this.getTargetBlock().getX() + x, y + 1, this.getTargetBlock().getZ() + z);
if (check == 0 || check == 8 || check == 9) if (check == 0 || check == 8 || check == 9) {
{
// must start at surface... this prevents it filling stuff in if you click in a wall // must start at surface... this prevents it filling stuff in if you click in a wall
// and it starts out below surface. // and it starts out below surface.
if (!this.allBlocks) if (!this.allBlocks) {
{
// if the override parameter has not been activated, go to the switch that filters out manmade stuff. // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z)); BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z));
BlockMaterial mat = type.getMaterial(); BlockMaterial mat = type.getMaterial();
@ -151,14 +128,10 @@ public class SplatterOverlayBrush extends PerformBrush
} else { } else {
continue; continue;
} }
} } else {
else
{
final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth; final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth;
for (int d = this.depth - 1; ((this.depth - d) <= depth); d--) for (int d = this.depth - 1; ((this.depth - d) <= depth); d--) {
{ if (!this.clampY(this.getTargetBlock().getX() + x, y - d, this.getTargetBlock().getZ() + z).isEmpty()) {
if (!this.clampY(this.getTargetBlock().getX() + x, y - d, this.getTargetBlock().getZ() + z).isEmpty())
{
// fills down as many layers as you specify in parameters // fills down as many layers as you specify in parameters
this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y - d + yOffset, this.getTargetBlock().getZ() + z)); this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y - d + yOffset, this.getTargetBlock().getZ() + z));
// stop it from checking any other blocks in this vertical 1x1 column. // stop it from checking any other blocks in this vertical 1x1 column.
@ -176,17 +149,13 @@ public class SplatterOverlayBrush extends PerformBrush
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void soverlayTwo(final SnipeData v) private void soverlayTwo(final SnipeData v) {
{
// Splatter Time // Splatter Time
final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array // Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) {
{
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent)
{
splat[x][y] = 1; splat[x][y] = 1;
} }
} }
@ -196,39 +165,30 @@ public class SplatterOverlayBrush extends PerformBrush
final int[][] tempsplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][] tempsplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
int growcheck; int growcheck;
for (int r = 0; r < this.splatterRecursions; r++) for (int r = 0; r < this.splatterRecursions; r++) {
{
this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); this.growPercent = gref - ((gref / this.splatterRecursions) * (r));
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
tempsplat[x][y] = splat[x][y]; // prime tempsplat tempsplat[x][y] = splat[x][y]; // prime tempsplat
growcheck = 0; growcheck = 0;
if (splat[x][y] == 0) if (splat[x][y] == 0) {
{ if (x != 0 && splat[x - 1][y] == 1) {
if (x != 0 && splat[x - 1][y] == 1)
{
growcheck++; growcheck++;
} }
if (y != 0 && splat[x][y - 1] == 1) if (y != 0 && splat[x][y - 1] == 1) {
{
growcheck++; growcheck++;
} }
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) {
{
growcheck++; growcheck++;
} }
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) {
{
growcheck++; growcheck++;
} }
} }
if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) {
{
tempsplat[x][y] = 1; // prevent bleed into splat tempsplat[x][y] = 1; // prevent bleed into splat
} }
@ -236,8 +196,7 @@ public class SplatterOverlayBrush extends PerformBrush
} }
// integrate tempsplat back into splat at end of iteration // integrate tempsplat back into splat at end of iteration
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{
if (2 * v.getBrushSize() + 1 >= 0) if (2 * v.getBrushSize() + 1 >= 0)
System.arraycopy(tempsplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); System.arraycopy(tempsplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1);
} }
@ -247,44 +206,32 @@ public class SplatterOverlayBrush extends PerformBrush
final int[][] memory = new int[v.getBrushSize() * 2 + 1][v.getBrushSize() * 2 + 1]; final int[][] memory = new int[v.getBrushSize() * 2 + 1][v.getBrushSize() * 2 + 1];
final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2); final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2);
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
{ for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) for (int y = this.getTargetBlock().getY(); y > 0; y--) { // start scanning from the height you clicked at
{ if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1) { // if haven't already found the surface in this column
for (int y = this.getTargetBlock().getY(); y > 0; y--) if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared && splat[x + v.getBrushSize()][z + v.getBrushSize()] == 1) { // if inside of the column...&& if to be splattered
{ // start scanning from the height you clicked at if (!this.getBlockAt(this.getTargetBlock().getX() + x, y - 1, this.getTargetBlock().getZ() + z).isEmpty()) { // if not a floating block (like one of Notch'world pools)
if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1) if (this.getBlockAt(this.getTargetBlock().getX() + x, y + 1, this.getTargetBlock().getZ() + z).isEmpty()) { // must start at surface... this prevents it filling stuff in if
{ // if haven't already found the surface in this column
if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared && splat[x + v.getBrushSize()][z + v.getBrushSize()] == 1)
{ // if inside of the column...&& if to be splattered
if (!this.getBlockAt(this.getTargetBlock().getX() + x, y - 1, this.getTargetBlock().getZ() + z).isEmpty())
{ // if not a floating block (like one of Notch'world pools)
if (this.getBlockAt(this.getTargetBlock().getX() + x, y + 1, this.getTargetBlock().getZ() + z).isEmpty())
{ // must start at surface... this prevents it filling stuff in if
// you click in a wall and it starts out below surface. // you click in a wall and it starts out below surface.
if (!this.allBlocks) if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
{ // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z)); BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z));
BlockMaterial mat = type.getMaterial(); BlockMaterial mat = type.getMaterial();
if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer()) if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer()) {
{ final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth;
final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth; for (int d = 1; (d < depth + 1); d++) {
for (int d = 1; (d < depth + 1); d++) { this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d + yOffset, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify
this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d + yOffset, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify // in parameters
// in parameters memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column.
memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. }
} continue;
continue;
} else { } else {
continue; continue;
} }
} } else {
else
{
final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth; final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth;
for (int d = 1; (d < depth + 1); d++) for (int d = 1; (d < depth + 1); d++) {
{
this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d + yOffset, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d + yOffset, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in
// parameters // parameters
memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column.
@ -302,30 +249,24 @@ public class SplatterOverlayBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.sOverlay(v); this.sOverlay(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.soverlayTwo(v); this.soverlayTwo(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{ if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
this.seedPercent = SEED_PERCENT_DEFAULT; this.seedPercent = SEED_PERCENT_DEFAULT;
} }
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
{
this.growPercent = GROW_PERCENT_DEFAULT; this.growPercent = GROW_PERCENT_DEFAULT;
} }
if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) {
{
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
} }
vm.brushName(this.getName()); vm.brushName(this.getName());
@ -337,15 +278,11 @@ public class SplatterOverlayBrush extends PerformBrush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
try try {
{ if (parameter.equalsIgnoreCase("info")) {
if (parameter.equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Splatter Overlay brush parameters:"); v.sendMessage(ChatColor.GOLD + "Splatter Overlay brush parameters:");
v.sendMessage(ChatColor.AQUA + "d[number] (ex: d3) How many blocks deep you want to replace from the surface."); v.sendMessage(ChatColor.AQUA + "d[number] (ex: d3) How many blocks deep you want to replace from the surface.");
v.sendMessage(ChatColor.BLUE + "all (ex: /b over all) Sets the brush to overlay over ALL materials, not just natural surface ones (will no longer ignore trees and buildings). The parameter /some will set it back to default."); v.sendMessage(ChatColor.BLUE + "all (ex: /b over all) Sets the brush to overlay over ALL materials, not just natural surface ones (will no longer ignore trees and buildings). The parameter /some will set it back to default.");
@ -353,98 +290,64 @@ public class SplatterOverlayBrush extends PerformBrush
v.sendMessage(ChatColor.AQUA + "/b sover g[int] -- set a growth percentage (1-9999). Default is 1000"); v.sendMessage(ChatColor.AQUA + "/b sover g[int] -- set a growth percentage (1-9999). Default is 1000");
v.sendMessage(ChatColor.AQUA + "/b sover r[int] -- set a recursion (1-10). Default is 3"); v.sendMessage(ChatColor.AQUA + "/b sover r[int] -- set a recursion (1-10). Default is 3");
return; return;
} } else if (parameter.startsWith("d")) {
else if (parameter.startsWith("d"))
{
this.depth = Integer.parseInt(parameter.replace("d", "")); this.depth = Integer.parseInt(parameter.replace("d", ""));
v.sendMessage(ChatColor.AQUA + "Depth set to " + this.depth); v.sendMessage(ChatColor.AQUA + "Depth set to " + this.depth);
if (this.depth < 1) if (this.depth < 1) {
{
this.depth = 1; this.depth = 1;
} }
} } else if (parameter.startsWith("all")) {
else if (parameter.startsWith("all"))
{
this.allBlocks = true; this.allBlocks = true;
v.sendMessage(ChatColor.BLUE + "Will overlay over any block." + this.depth); v.sendMessage(ChatColor.BLUE + "Will overlay over any block." + this.depth);
} } else if (parameter.startsWith("some")) {
else if (parameter.startsWith("some"))
{
this.allBlocks = false; this.allBlocks = false;
v.sendMessage(ChatColor.BLUE + "Will overlay only natural block types." + this.depth); v.sendMessage(ChatColor.BLUE + "Will overlay only natural block types." + this.depth);
} } else if (par[i].startsWith("s")) {
else if (par[i].startsWith("s"))
{
final double temp = Integer.parseInt(parameter.replace("s", "")); final double temp = Integer.parseInt(parameter.replace("s", ""));
if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%");
this.seedPercent = (int) temp; this.seedPercent = (int) temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!"); v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!");
} }
} } else if (parameter.startsWith("g")) {
else if (parameter.startsWith("g"))
{
final double temp = Integer.parseInt(parameter.replace("g", "")); final double temp = Integer.parseInt(parameter.replace("g", ""));
if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%");
this.growPercent = (int) temp; this.growPercent = (int) temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!"); v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!");
} }
} } else if (parameter.startsWith("randh")) {
else if (parameter.startsWith("randh"))
{
randomizeHeight = !randomizeHeight; randomizeHeight = !randomizeHeight;
v.sendMessage(ChatColor.RED + "RandomizeHeight set to: " + randomizeHeight); v.sendMessage(ChatColor.RED + "RandomizeHeight set to: " + randomizeHeight);
} } else if (parameter.startsWith("r")) {
else if (parameter.startsWith("r"))
{
final int temp = Integer.parseInt(parameter.replace("r", "")); final int temp = Integer.parseInt(parameter.replace("r", ""));
if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp); v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp);
this.splatterRecursions = temp; this.splatterRecursions = temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!");
} }
} } else if (parameter.startsWith("yoff")) {
else if (parameter.startsWith("yoff"))
{
final int temp = Integer.parseInt(parameter.replace("yoff", "")); final int temp = Integer.parseInt(parameter.replace("yoff", ""));
if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Y-Offset set to: " + temp); v.sendMessage(ChatColor.AQUA + "Y-Offset set to: " + temp);
this.yOffset = temp; this.yOffset = temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!");
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} } catch (Exception exception) {
catch (Exception exception)
{
v.sendMessage(String.format("An error occured while processing parameter %s.", parameter)); v.sendMessage(String.format("An error occured while processing parameter %s.", parameter));
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.splatteroverlay"; return "voxelsniper.brush.splatteroverlay";
} }
} }

Datei anzeigen

@ -5,7 +5,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import java.util.Random; import java.util.Random;
@ -14,8 +13,7 @@ import java.util.Random;
* *
* @author Voxel * @author Voxel
*/ */
public class SplatterVoxelBrush extends PerformBrush public class SplatterVoxelBrush extends PerformBrush {
{
private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_MIN = 1;
private static final int GROW_PERCENT_DEFAULT = 1000; private static final int GROW_PERCENT_DEFAULT = 1000;
private static final int GROW_PERCENT_MAX = 9999; private static final int GROW_PERCENT_MAX = 9999;
@ -33,39 +31,30 @@ public class SplatterVoxelBrush extends PerformBrush
/** /**
* *
*/ */
public SplatterVoxelBrush() public SplatterVoxelBrush() {
{
this.setName("Splatter Voxel"); this.setName("Splatter Voxel");
} }
private void vSplatterBall(final SnipeData v, AsyncBlock targetBlock) private void vSplatterBall(final SnipeData v, AsyncBlock targetBlock) {
{ if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%"); v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%");
this.seedPercent = SEED_PERCENT_DEFAULT; this.seedPercent = SEED_PERCENT_DEFAULT;
} }
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
{
v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%"); v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%");
this.growPercent = GROW_PERCENT_DEFAULT; this.growPercent = GROW_PERCENT_DEFAULT;
} }
if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) {
{
v.sendMessage(ChatColor.BLUE + "Recursions set to: 3"); v.sendMessage(ChatColor.BLUE + "Recursions set to: 3");
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
} }
final int[][][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array // Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
{ if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) {
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent)
{
splat[x][y][z] = 1; splat[x][y][z] = 1;
} }
} }
@ -76,49 +65,37 @@ public class SplatterVoxelBrush extends PerformBrush
final int[][][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
int growcheck; int growcheck;
for (int r = 0; r < this.splatterRecursions; r++) for (int r = 0; r < this.splatterRecursions; r++) {
{
this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); this.growPercent = gref - ((gref / this.splatterRecursions) * (r));
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
{
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
tempSplat[x][y][z] = splat[x][y][z]; // prime tempsplat tempSplat[x][y][z] = splat[x][y][z]; // prime tempsplat
growcheck = 0; growcheck = 0;
if (splat[x][y][z] == 0) if (splat[x][y][z] == 0) {
{ if (x != 0 && splat[x - 1][y][z] == 1) {
if (x != 0 && splat[x - 1][y][z] == 1)
{
growcheck++; growcheck++;
} }
if (y != 0 && splat[x][y - 1][z] == 1) if (y != 0 && splat[x][y - 1][z] == 1) {
{
growcheck++; growcheck++;
} }
if (z != 0 && splat[x][y][z - 1] == 1) if (z != 0 && splat[x][y][z - 1] == 1) {
{
growcheck++; growcheck++;
} }
if (x != 2 * v.getBrushSize() && splat[x + 1][y][z] == 1) if (x != 2 * v.getBrushSize() && splat[x + 1][y][z] == 1) {
{
growcheck++; growcheck++;
} }
if (y != 2 * v.getBrushSize() && splat[x][y + 1][z] == 1) if (y != 2 * v.getBrushSize() && splat[x][y + 1][z] == 1) {
{
growcheck++; growcheck++;
} }
if (z != 2 * v.getBrushSize() && splat[x][y][z + 1] == 1) if (z != 2 * v.getBrushSize() && splat[x][y][z + 1] == 1) {
{
growcheck++; growcheck++;
} }
} }
if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) {
{
tempSplat[x][y][z] = 1; // prevent bleed into splat tempSplat[x][y][z] = 1; // prevent bleed into splat
} }
@ -126,26 +103,20 @@ public class SplatterVoxelBrush extends PerformBrush
} }
} }
// integrate tempsplat back into splat at end of iteration // integrate tempsplat back into splat at end of iteration
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
if (2 * v.getBrushSize() + 1 >= 0) if (2 * v.getBrushSize() + 1 >= 0)
System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0,
2 * v.getBrushSize() + 1); 2 * v.getBrushSize() + 1);
} }
} }
} }
this.growPercent = gref; this.growPercent = gref;
// Fill 1x1x1 holes // Fill 1x1x1 holes
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
{ if (splat[Math.max(x - 1, 0)][y][z] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y][z] == 1 && splat[x][Math.max(0, y - 1)][z] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)][z] == 1) {
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
if (splat[Math.max(x - 1, 0)][y][z] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y][z] == 1 && splat[x][Math.max(0, y - 1)][z] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)][z] == 1)
{
splat[x][y][z] = 1; splat[x][y][z] = 1;
} }
} }
@ -154,14 +125,10 @@ public class SplatterVoxelBrush extends PerformBrush
// Make the changes // Make the changes
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
{ if (splat[x][y][z] == 1) {
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
if (splat[x][y][z] == 1)
{
current.perform(targetBlock.getRelative(-v.getBrushSize() + x, -v.getBrushSize() + z, -v.getBrushSize() + y)); current.perform(targetBlock.getRelative(-v.getBrushSize() + x, -v.getBrushSize() + z, -v.getBrushSize() + y));
} }
} }
@ -171,30 +138,24 @@ public class SplatterVoxelBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.vSplatterBall(v, this.getTargetBlock()); this.vSplatterBall(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.vSplatterBall(v, this.getLastBlock()); this.vSplatterBall(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{ if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
this.seedPercent = SEED_PERCENT_DEFAULT; this.seedPercent = SEED_PERCENT_DEFAULT;
} }
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
{
this.growPercent = GROW_PERCENT_DEFAULT; this.growPercent = GROW_PERCENT_DEFAULT;
} }
if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) {
{
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
} }
vm.brushName("Splatter Voxel"); vm.brushName("Splatter Voxel");
@ -205,69 +166,48 @@ public class SplatterVoxelBrush extends PerformBrush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++)
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Splatter Voxel brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Splatter Voxel brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b sv s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000"); v.sendMessage(ChatColor.AQUA + "/b sv s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000");
v.sendMessage(ChatColor.AQUA + "/b sv g[int] -- set a growth percentage (1-9999). Default is 1000"); v.sendMessage(ChatColor.AQUA + "/b sv g[int] -- set a growth percentage (1-9999). Default is 1000");
v.sendMessage(ChatColor.AQUA + "/b sv r[int] -- set a recursion (1-10). Default is 3"); v.sendMessage(ChatColor.AQUA + "/b sv r[int] -- set a recursion (1-10). Default is 3");
return; return;
} } else if (parameter.startsWith("s")) {
else if (parameter.startsWith("s"))
{
final double temp = Integer.parseInt(parameter.replace("s", "")); final double temp = Integer.parseInt(parameter.replace("s", ""));
if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%");
this.seedPercent = (int) temp; this.seedPercent = (int) temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!"); v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!");
} }
} } else if (parameter.startsWith("g")) {
else if (parameter.startsWith("g"))
{
final double temp = Integer.parseInt(parameter.replace("g", "")); final double temp = Integer.parseInt(parameter.replace("g", ""));
if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%");
this.growPercent = (int) temp; this.growPercent = (int) temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!"); v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!");
} }
} } else if (parameter.startsWith("r")) {
else if (parameter.startsWith("r"))
{
final int temp = Integer.parseInt(parameter.replace("r", "")); final int temp = Integer.parseInt(parameter.replace("r", ""));
if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp); v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp);
this.splatterRecursions = temp; this.splatterRecursions = temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!");
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.splattervoxel"; return "voxelsniper.brush.splattervoxel";
} }
} }

Datei anzeigen

@ -13,8 +13,7 @@ import java.util.Random;
* *
* @author Voxel * @author Voxel
*/ */
public class SplatterVoxelDiscBrush extends PerformBrush public class SplatterVoxelDiscBrush extends PerformBrush {
{
private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_MIN = 1;
private static final int GROW_PERCENT_DEFAULT = 1000; private static final int GROW_PERCENT_DEFAULT = 1000;
private static final int GROW_PERCENT_MAX = 9999; private static final int GROW_PERCENT_MAX = 9999;
@ -32,37 +31,29 @@ public class SplatterVoxelDiscBrush extends PerformBrush
/** /**
* *
*/ */
public SplatterVoxelDiscBrush() public SplatterVoxelDiscBrush() {
{
this.setName("Splatter Voxel Disc"); this.setName("Splatter Voxel Disc");
} }
private void vSplatterDisc(final SnipeData v, Block targetBlock) private void vSplatterDisc(final SnipeData v, Block targetBlock) {
{ if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%"); v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%");
this.seedPercent = SEED_PERCENT_DEFAULT; this.seedPercent = SEED_PERCENT_DEFAULT;
} }
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
{
v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%"); v.sendMessage(ChatColor.BLUE + "Growth percent set to: 10%");
this.growPercent = GROW_PERCENT_DEFAULT; this.growPercent = GROW_PERCENT_DEFAULT;
} }
if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) {
{
v.sendMessage(ChatColor.BLUE + "Recursions set to: 3"); v.sendMessage(ChatColor.BLUE + "Recursions set to: 3");
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
} }
final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array // Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) {
{
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent)
{
splat[x][y] = 1; splat[x][y] = 1;
} }
} }
@ -72,57 +63,44 @@ public class SplatterVoxelDiscBrush extends PerformBrush
final int[][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1]; final int[][] tempSplat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
int growcheck; int growcheck;
for (int r = 0; r < this.splatterRecursions; r++) for (int r = 0; r < this.splatterRecursions; r++) {
{
this.growPercent = gref - ((gref / this.splatterRecursions) * (r)); this.growPercent = gref - ((gref / this.splatterRecursions) * (r));
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
tempSplat[x][y] = splat[x][y]; // prime tempsplat tempSplat[x][y] = splat[x][y]; // prime tempsplat
growcheck = 0; growcheck = 0;
if (splat[x][y] == 0) if (splat[x][y] == 0) {
{ if (x != 0 && splat[x - 1][y] == 1) {
if (x != 0 && splat[x - 1][y] == 1)
{
growcheck++; growcheck++;
} }
if (y != 0 && splat[x][y - 1] == 1) if (y != 0 && splat[x][y - 1] == 1) {
{
growcheck++; growcheck++;
} }
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) {
{
growcheck++; growcheck++;
} }
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) {
{
growcheck++; growcheck++;
} }
} }
if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) if (growcheck >= 1 && this.generator.nextInt(GROW_PERCENT_MAX + 1) <= this.growPercent) {
{
tempSplat[x][y] = 1; // prevent bleed into splat tempSplat[x][y] = 1; // prevent bleed into splat
} }
} }
} }
// integrate tempsplat back into splat at end of iteration // integrate tempsplat back into splat at end of iteration
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{
if (2 * v.getBrushSize() + 1 >= 0) if (2 * v.getBrushSize() + 1 >= 0)
System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1);
} }
} }
this.growPercent = gref; this.growPercent = gref;
// Fill 1x1 holes // Fill 1x1 holes
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) if (splat[Math.max(x - 1, 0)][y] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y] == 1 && splat[x][Math.max(0, y - 1)] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)] == 1) {
{
if (splat[Math.max(x - 1, 0)][y] == 1 && splat[Math.min(x + 1, 2 * v.getBrushSize())][y] == 1 && splat[x][Math.max(0, y - 1)] == 1 && splat[x][Math.min(2 * v.getBrushSize(), y + 1)] == 1)
{
splat[x][y] = 1; splat[x][y] = 1;
} }
} }
@ -130,12 +108,9 @@ public class SplatterVoxelDiscBrush extends PerformBrush
// Make the changes // Make the changes
for (int x = 2 * v.getBrushSize(); x >= 0; x--) for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
{ for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) if (splat[x][y] == 1) {
{
if (splat[x][y] == 1)
{
this.current.perform(this.clampY(targetBlock.getX() - v.getBrushSize() + x, targetBlock.getY(), targetBlock.getZ() - v.getBrushSize() + y)); this.current.perform(this.clampY(targetBlock.getX() - v.getBrushSize() + x, targetBlock.getY(), targetBlock.getZ() - v.getBrushSize() + y));
} }
} }
@ -144,30 +119,24 @@ public class SplatterVoxelDiscBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.vSplatterDisc(v, this.getTargetBlock()); this.vSplatterDisc(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.vSplatterDisc(v, this.getLastBlock()); this.vSplatterDisc(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{ if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
this.seedPercent = SEED_PERCENT_DEFAULT; this.seedPercent = SEED_PERCENT_DEFAULT;
} }
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
{
this.growPercent = GROW_PERCENT_DEFAULT; this.growPercent = GROW_PERCENT_DEFAULT;
} }
if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) if (this.splatterRecursions < SPLATREC_PERCENT_MIN || this.splatterRecursions > SPLATREC_PERCENT_MAX) {
{
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT; this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
} }
vm.brushName("Splatter Voxel Disc"); vm.brushName("Splatter Voxel Disc");
@ -179,70 +148,49 @@ public class SplatterVoxelDiscBrush extends PerformBrush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{
for (int i = 1; i < par.length; i++) for (int i = 1; i < par.length; i++) {
{
final String parameter = par[i]; final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) if (parameter.equalsIgnoreCase("info")) {
{
v.sendMessage(ChatColor.GOLD + "Splatter Voxel Disc brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Splatter Voxel Disc brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b svd s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000"); v.sendMessage(ChatColor.AQUA + "/b svd s[int] -- set a seed percentage (1-9999). 100 = 1% Default is 1000");
v.sendMessage(ChatColor.AQUA + "/b svd g[int] -- set a growth percentage (1-9999). Default is 1000"); v.sendMessage(ChatColor.AQUA + "/b svd g[int] -- set a growth percentage (1-9999). Default is 1000");
v.sendMessage(ChatColor.AQUA + "/b svd r[int] -- set a recursion (1-10). Default is 3"); v.sendMessage(ChatColor.AQUA + "/b svd r[int] -- set a recursion (1-10). Default is 3");
return; return;
} } else if (parameter.startsWith("s")) {
else if (parameter.startsWith("s"))
{
final double temp = Integer.parseInt(parameter.replace("s", "")); final double temp = Integer.parseInt(parameter.replace("s", ""));
if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) if (temp >= SEED_PERCENT_MIN && temp <= SEED_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Seed percent set to: " + temp / 100 + "%");
this.seedPercent = (int) temp; this.seedPercent = (int) temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!"); v.sendMessage(ChatColor.RED + "Seed percent must be an integer 1-9999!");
} }
} } else if (parameter.startsWith("g")) {
else if (parameter.startsWith("g"))
{
final double temp = Integer.parseInt(parameter.replace("g", "")); final double temp = Integer.parseInt(parameter.replace("g", ""));
if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) if (temp >= GROW_PERCENT_MIN && temp <= GROW_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%"); v.sendMessage(ChatColor.AQUA + "Growth percent set to: " + temp / 100 + "%");
this.growPercent = (int) temp; this.growPercent = (int) temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!"); v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!");
} }
} } else if (parameter.startsWith("r")) {
else if (parameter.startsWith("r"))
{
final int temp = Integer.parseInt(parameter.replace("r", "")); final int temp = Integer.parseInt(parameter.replace("r", ""));
if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) if (temp >= SPLATREC_PERCENT_MIN && temp <= SPLATREC_PERCENT_MAX) {
{
v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp); v.sendMessage(ChatColor.AQUA + "Recursions set to: " + temp);
this.splatterRecursions = temp; this.splatterRecursions = temp;
} } else {
else
{
v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!");
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.splattervoxeldisc"; return "voxelsniper.brush.splattervoxeldisc";
} }
} }

Datei anzeigen

@ -14,8 +14,7 @@ import java.util.ArrayList;
* *
* @author psanker * @author psanker
*/ */
public class SplineBrush extends PerformBrush public class SplineBrush extends PerformBrush {
{
private final ArrayList<Block> endPts = new ArrayList<>(); private final ArrayList<Block> endPts = new ArrayList<>();
private final ArrayList<Block> ctrlPts = new ArrayList<>(); private final ArrayList<Block> ctrlPts = new ArrayList<>();
protected ArrayList<Point> spline = new ArrayList<>(); protected ArrayList<Point> spline = new ArrayList<>();
@ -23,17 +22,13 @@ public class SplineBrush extends PerformBrush
protected boolean ctrl; protected boolean ctrl;
protected String[] sparams = {"ss", "sc", "clear"}; protected String[] sparams = {"ss", "sc", "clear"};
public SplineBrush() public SplineBrush() {
{
this.setName("Spline"); this.setName("Spline");
} }
public final void addToSet(final SnipeData v, final boolean ep, Block targetBlock) public final void addToSet(final SnipeData v, final boolean ep, Block targetBlock) {
{ if (ep) {
if (ep) if (this.endPts.contains(targetBlock) || this.endPts.size() == 2) {
{
if (this.endPts.contains(targetBlock) || this.endPts.size() == 2)
{
return; return;
} }
@ -42,8 +37,7 @@ public class SplineBrush extends PerformBrush
return; return;
} }
if (this.ctrlPts.contains(targetBlock) || this.ctrlPts.size() == 2) if (this.ctrlPts.contains(targetBlock) || this.ctrlPts.size() == 2) {
{
return; return;
} }
@ -52,12 +46,9 @@ public class SplineBrush extends PerformBrush
+ "to control point selection"); + "to control point selection");
} }
public final void removeFromSet(final SnipeData v, final boolean ep, Block targetBlock) public final void removeFromSet(final SnipeData v, final boolean ep, Block targetBlock) {
{ if (ep) {
if (ep) if (!this.endPts.contains(targetBlock)) {
{
if (!this.endPts.contains(targetBlock))
{
v.sendMessage(ChatColor.RED + "That block is not in the endpoint selection set."); v.sendMessage(ChatColor.RED + "That block is not in the endpoint selection set.");
return; return;
} }
@ -68,8 +59,7 @@ public class SplineBrush extends PerformBrush
return; return;
} }
if (!this.ctrlPts.contains(targetBlock)) if (!this.ctrlPts.contains(targetBlock)) {
{
v.sendMessage(ChatColor.RED + "That block is not in the control point selection set."); v.sendMessage(ChatColor.RED + "That block is not in the control point selection set.");
return; return;
} }
@ -79,46 +69,37 @@ public class SplineBrush extends PerformBrush
+ "from control point selection"); + "from control point selection");
} }
public final boolean spline(final Point start, final Point end, final Point c1, final Point c2, final SnipeData v) public final boolean spline(final Point start, final Point end, final Point c1, final Point c2, final SnipeData v) {
{
this.spline.clear(); this.spline.clear();
try try {
{
final Point c = (c1.subtract(start)).multiply(3); final Point c = (c1.subtract(start)).multiply(3);
final Point b = ((c2.subtract(c1)).multiply(3)).subtract(c); final Point b = ((c2.subtract(c1)).multiply(3)).subtract(c);
final Point a = ((end.subtract(start)).subtract(c)).subtract(b); final Point a = ((end.subtract(start)).subtract(c)).subtract(b);
for (double t = 0.0; t < 1.0; t += 0.01) for (double t = 0.0; t < 1.0; t += 0.01) {
{
final int px = (int) Math.round((a.getX() * (t * t * t)) + (b.getX() * (t * t)) + (c.getX() * t) + this.endPts.get(0).getX()); final int px = (int) Math.round((a.getX() * (t * t * t)) + (b.getX() * (t * t)) + (c.getX() * t) + this.endPts.get(0).getX());
final int py = (int) Math.round((a.getY() * (t * t * t)) + (b.getY() * (t * t)) + (c.getY() * t) + this.endPts.get(0).getY()); final int py = (int) Math.round((a.getY() * (t * t * t)) + (b.getY() * (t * t)) + (c.getY() * t) + this.endPts.get(0).getY());
final int pz = (int) Math.round((a.getZ() * (t * t * t)) + (b.getZ() * (t * t)) + (c.getZ() * t) + this.endPts.get(0).getZ()); final int pz = (int) Math.round((a.getZ() * (t * t * t)) + (b.getZ() * (t * t)) + (c.getZ() * t) + this.endPts.get(0).getZ());
if (!this.spline.contains(new Point(px, py, pz))) if (!this.spline.contains(new Point(px, py, pz))) {
{
this.spline.add(new Point(px, py, pz)); this.spline.add(new Point(px, py, pz));
} }
} }
return true; return true;
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "Not enough points selected; " + this.endPts.size() + " endpoints, " + this.ctrlPts.size() + " control points"); v.sendMessage(ChatColor.RED + "Not enough points selected; " + this.endPts.size() + " endpoints, " + this.ctrlPts.size() + " control points");
return false; return false;
} }
} }
protected final void render(final SnipeData v) protected final void render(final SnipeData v) {
{ if (this.spline.isEmpty()) {
if (this.spline.isEmpty())
{
return; return;
} }
for (final Point point : this.spline) for (final Point point : this.spline) {
{
this.current.perform(this.clampY(point.getX(), point.getY(), point.getZ())); this.current.perform(this.clampY(point.getX(), point.getY(), point.getZ()));
} }
@ -126,20 +107,15 @@ public class SplineBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ if (this.set) {
if (this.set)
{
this.removeFromSet(v, true, this.getTargetBlock()); this.removeFromSet(v, true, this.getTargetBlock());
} } else if (this.ctrl) {
else if (this.ctrl)
{
this.removeFromSet(v, false, this.getTargetBlock()); this.removeFromSet(v, false, this.getTargetBlock());
} }
} }
protected final void clear(final SnipeData v) protected final void clear(final SnipeData v) {
{
this.spline.clear(); this.spline.clear();
this.ctrlPts.clear(); this.ctrlPts.clear();
this.endPts.clear(); this.endPts.clear();
@ -147,44 +123,32 @@ public class SplineBrush extends PerformBrush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (this.set) {
if (this.set)
{
this.addToSet(v, true, this.getTargetBlock()); this.addToSet(v, true, this.getTargetBlock());
} }
if (this.ctrl) if (this.ctrl) {
{
this.addToSet(v, false, this.getTargetBlock()); this.addToSet(v, false, this.getTargetBlock());
} }
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
if (this.set) if (this.set) {
{
vm.custom(ChatColor.GRAY + "Endpoint selection mode ENABLED."); vm.custom(ChatColor.GRAY + "Endpoint selection mode ENABLED.");
} } else if (this.ctrl) {
else if (this.ctrl)
{
vm.custom(ChatColor.GRAY + "Control point selection mode ENABLED."); vm.custom(ChatColor.GRAY + "Control point selection mode ENABLED.");
} } else {
else
{
vm.custom(ChatColor.AQUA + "No selection mode enabled."); vm.custom(ChatColor.AQUA + "No selection mode enabled.");
} }
} }
@Override @Override
public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++) if (par[i].equalsIgnoreCase("info")) {
{
if (par[i].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Spline brush parameters"); v.sendMessage(ChatColor.GOLD + "Spline brush parameters");
v.sendMessage(ChatColor.AQUA + "ss: Enable endpoint selection mode for desired curve"); v.sendMessage(ChatColor.AQUA + "ss: Enable endpoint selection mode for desired curve");
v.sendMessage(ChatColor.AQUA + "sc: Enable control point selection mode for desired curve"); v.sendMessage(ChatColor.AQUA + "sc: Enable control point selection mode for desired curve");
@ -192,122 +156,93 @@ public class SplineBrush extends PerformBrush
v.sendMessage(ChatColor.AQUA + "ren: Render curve from control points"); v.sendMessage(ChatColor.AQUA + "ren: Render curve from control points");
return; return;
} }
if (par[i].equalsIgnoreCase("sc")) if (par[i].equalsIgnoreCase("sc")) {
{ if (!this.ctrl) {
if (!this.ctrl)
{
this.set = false; this.set = false;
this.ctrl = true; this.ctrl = true;
v.sendMessage(ChatColor.GRAY + "Control point selection mode ENABLED."); v.sendMessage(ChatColor.GRAY + "Control point selection mode ENABLED.");
} } else {
else
{
this.ctrl = false; this.ctrl = false;
v.sendMessage(ChatColor.AQUA + "Control point selection mode disabled."); v.sendMessage(ChatColor.AQUA + "Control point selection mode disabled.");
} }
} } else if (par[i].equalsIgnoreCase("ss")) {
else if (par[i].equalsIgnoreCase("ss")) if (!this.set) {
{
if (!this.set)
{
this.set = true; this.set = true;
this.ctrl = false; this.ctrl = false;
v.sendMessage(ChatColor.GRAY + "Endpoint selection mode ENABLED."); v.sendMessage(ChatColor.GRAY + "Endpoint selection mode ENABLED.");
} } else {
else
{
this.set = false; this.set = false;
v.sendMessage(ChatColor.AQUA + "Endpoint selection mode disabled."); v.sendMessage(ChatColor.AQUA + "Endpoint selection mode disabled.");
} }
} } else if (par[i].equalsIgnoreCase("clear")) {
else if (par[i].equalsIgnoreCase("clear"))
{
this.clear(v); this.clear(v);
} } else if (par[i].equalsIgnoreCase("ren")) {
else if (par[i].equalsIgnoreCase("ren")) if (this.spline(new Point(this.endPts.get(0)), new Point(this.endPts.get(1)), new Point(this.ctrlPts.get(0)), new Point(this.ctrlPts.get(1)), v)) {
{
if (this.spline(new Point(this.endPts.get(0)), new Point(this.endPts.get(1)), new Point(this.ctrlPts.get(0)), new Point(this.ctrlPts.get(1)), v))
{
this.render(v); this.render(v);
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override
public String getPermissionNode() {
return "voxelsniper.brush.spline";
}
// Vector class for splines // Vector class for splines
protected class Point protected class Point {
{
private int x; private int x;
private int y; private int y;
private int z; private int z;
public Point(final Block b) public Point(final Block b) {
{
this.setX(b.getX()); this.setX(b.getX());
this.setY(b.getY()); this.setY(b.getY());
this.setZ(b.getZ()); this.setZ(b.getZ());
} }
public Point(final int x, final int y, final int z) public Point(final int x, final int y, final int z) {
{
this.setX(x); this.setX(x);
this.setY(y); this.setY(y);
this.setZ(z); this.setZ(z);
} }
public final Point add(final Point p) public final Point add(final Point p) {
{
return new Point(this.getX() + p.getX(), this.getY() + p.getY(), this.getZ() + p.getZ()); return new Point(this.getX() + p.getX(), this.getY() + p.getY(), this.getZ() + p.getZ());
} }
public final Point multiply(final int scalar) public final Point multiply(final int scalar) {
{
return new Point(this.getX() * scalar, this.getY() * scalar, this.getZ() * scalar); return new Point(this.getX() * scalar, this.getY() * scalar, this.getZ() * scalar);
} }
public final Point subtract(final Point p) public final Point subtract(final Point p) {
{
return new Point(this.getX() - p.getX(), this.getY() - p.getY(), this.getZ() - p.getZ()); return new Point(this.getX() - p.getX(), this.getY() - p.getY(), this.getZ() - p.getZ());
} }
public int getX() public int getX() {
{
return x; return x;
} }
public void setX(int x) public void setX(int x) {
{
this.x = x; this.x = x;
} }
public int getY() public int getY() {
{
return y; return y;
} }
public void setY(int y) public void setY(int y) {
{
this.y = y; this.y = y;
} }
public int getZ() public int getZ() {
{
return z; return z;
} }
public void setZ(int z) public void setZ(int z) {
{
this.z = z; this.z = z;
} }
} }
@Override
public String getPermissionNode()
{
return "voxelsniper.brush.spline";
}
} }

Datei anzeigen

@ -1,99 +1,52 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import java.util.HashSet;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import java.util.HashSet;
/** /**
* *
*/ */
public class StampBrush extends Brush public class StampBrush extends Brush {
{
/**
* @author Voxel
*/
protected class BlockWrapper
{
public int id;
public int x;
public int y;
public int z;
public int d;
/**
* @param b
* @param blx
* @param bly
* @param blz
*/
@SuppressWarnings("deprecation")
public BlockWrapper(final AsyncBlock b, final int blx, final int bly, final int blz)
{
this.id = b.getTypeId();
this.d = b.getPropertyId();
this.x = blx;
this.y = bly;
this.z = blz;
}
}
/**
* @author Monofraps
*/
protected enum StampType
{
NO_AIR, FILL, DEFAULT
}
protected HashSet<BlockWrapper> clone = new HashSet<>(); protected HashSet<BlockWrapper> clone = new HashSet<>();
protected HashSet<BlockWrapper> fall = new HashSet<>(); protected HashSet<BlockWrapper> fall = new HashSet<>();
protected HashSet<BlockWrapper> drop = new HashSet<>(); protected HashSet<BlockWrapper> drop = new HashSet<>();
protected HashSet<BlockWrapper> solid = new HashSet<>(); protected HashSet<BlockWrapper> solid = new HashSet<>();
protected Undo undo; protected Undo undo;
protected boolean sorted = false; protected boolean sorted = false;
protected StampType stamp = StampType.DEFAULT; protected StampType stamp = StampType.DEFAULT;
/** /**
* *
*/ */
public StampBrush() public StampBrush() {
{
this.setName("Stamp"); this.setName("Stamp");
} }
/** /**
* *
*/ */
public final void reSort() public final void reSort() {
{
this.sorted = false; this.sorted = false;
} }
/** /**
* @param id * @param id
*
* @return * @return
*/ */
protected final boolean falling(final int id) protected final boolean falling(final int id) {
{
return (id > 7 && id < 14); return (id > 7 && id < 14);
} }
/** /**
* @param id * @param id
*
* @return * @return
*/ */
protected final boolean fallsOff(final int id) protected final boolean fallsOff(final int id) {
{
return (BlockTypes.get(id).getMaterial().isFragileWhenPushed()); return (BlockTypes.get(id).getMaterial().isFragileWhenPushed());
} }
@ -101,8 +54,7 @@ public class StampBrush extends Brush
* @param cb * @param cb
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected final void setBlock(final BlockWrapper cb) protected final void setBlock(final BlockWrapper cb) {
{
final AsyncBlock block = this.clampY(this.getTargetBlock().getX() + cb.x, this.getTargetBlock().getY() + cb.y, this.getTargetBlock().getZ() + cb.z); final AsyncBlock block = this.clampY(this.getTargetBlock().getX() + cb.x, this.getTargetBlock().getY() + cb.y, this.getTargetBlock().getZ() + cb.z);
this.undo.put(block); this.undo.put(block);
block.setTypeId(cb.id); block.setTypeId(cb.id);
@ -113,11 +65,9 @@ public class StampBrush extends Brush
* @param cb * @param cb
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected final void setBlockFill(final BlockWrapper cb) protected final void setBlockFill(final BlockWrapper cb) {
{
final AsyncBlock block = this.clampY(this.getTargetBlock().getX() + cb.x, this.getTargetBlock().getY() + cb.y, this.getTargetBlock().getZ() + cb.z); final AsyncBlock block = this.clampY(this.getTargetBlock().getX() + cb.x, this.getTargetBlock().getY() + cb.y, this.getTargetBlock().getZ() + cb.z);
if (block.isEmpty()) if (block.isEmpty()) {
{
this.undo.put(block); this.undo.put(block);
block.setTypeId(cb.id); block.setTypeId(cb.id);
block.setPropertyId(cb.d); block.setPropertyId(cb.d);
@ -127,60 +77,44 @@ public class StampBrush extends Brush
/** /**
* @param type * @param type
*/ */
protected final void setStamp(final StampType type) protected final void setStamp(final StampType type) {
{
this.stamp = type; this.stamp = type;
} }
/** /**
* @param v * @param v
*/ */
protected final void stamp(final SnipeData v) protected final void stamp(final SnipeData v) {
{
this.undo = new Undo(); this.undo = new Undo();
if (this.sorted) if (this.sorted) {
{ for (final BlockWrapper block : this.solid) {
for (final BlockWrapper block : this.solid)
{
this.setBlock(block); this.setBlock(block);
} }
for (final BlockWrapper block : this.drop) for (final BlockWrapper block : this.drop) {
{
this.setBlock(block); this.setBlock(block);
} }
for (final BlockWrapper block : this.fall) for (final BlockWrapper block : this.fall) {
{
this.setBlock(block); this.setBlock(block);
} }
} } else {
else
{
this.fall.clear(); this.fall.clear();
this.drop.clear(); this.drop.clear();
this.solid.clear(); this.solid.clear();
for (final BlockWrapper block : this.clone) for (final BlockWrapper block : this.clone) {
{ if (this.fallsOff(block.id)) {
if (this.fallsOff(block.id))
{
this.fall.add(block); this.fall.add(block);
} } else if (this.falling(block.id)) {
else if (this.falling(block.id))
{
this.drop.add(block); this.drop.add(block);
} } else {
else
{
this.solid.add(block); this.solid.add(block);
this.setBlock(block); this.setBlock(block);
} }
} }
for (final BlockWrapper block : this.drop) for (final BlockWrapper block : this.drop) {
{
this.setBlock(block); this.setBlock(block);
} }
for (final BlockWrapper block : this.fall) for (final BlockWrapper block : this.fall) {
{
this.setBlock(block); this.setBlock(block);
} }
this.sorted = true; this.sorted = true;
@ -192,53 +126,38 @@ public class StampBrush extends Brush
/** /**
* @param v * @param v
*/ */
protected final void stampFill(final SnipeData v) protected final void stampFill(final SnipeData v) {
{
this.undo = new Undo(); this.undo = new Undo();
if (this.sorted) if (this.sorted) {
{ for (final BlockWrapper block : this.solid) {
for (final BlockWrapper block : this.solid)
{
this.setBlockFill(block); this.setBlockFill(block);
} }
for (final BlockWrapper block : this.drop) for (final BlockWrapper block : this.drop) {
{
this.setBlockFill(block); this.setBlockFill(block);
} }
for (final BlockWrapper block : this.fall) for (final BlockWrapper block : this.fall) {
{
this.setBlockFill(block); this.setBlockFill(block);
} }
} } else {
else
{
this.fall.clear(); this.fall.clear();
this.drop.clear(); this.drop.clear();
this.solid.clear(); this.solid.clear();
for (final BlockWrapper block : this.clone) for (final BlockWrapper block : this.clone) {
{ if (this.fallsOff(block.id)) {
if (this.fallsOff(block.id))
{
this.fall.add(block); this.fall.add(block);
} } else if (this.falling(block.id)) {
else if (this.falling(block.id))
{
this.drop.add(block); this.drop.add(block);
} } else if (block.id != 0) {
else if (block.id != 0)
{
this.solid.add(block); this.solid.add(block);
this.setBlockFill(block); this.setBlockFill(block);
} }
} }
for (final BlockWrapper block : this.drop) for (final BlockWrapper block : this.drop) {
{
this.setBlockFill(block); this.setBlockFill(block);
} }
for (final BlockWrapper block : this.fall) for (final BlockWrapper block : this.fall) {
{
this.setBlockFill(block); this.setBlockFill(block);
} }
this.sorted = true; this.sorted = true;
@ -250,53 +169,38 @@ public class StampBrush extends Brush
/** /**
* @param v * @param v
*/ */
protected final void stampNoAir(final SnipeData v) protected final void stampNoAir(final SnipeData v) {
{
this.undo = new Undo(); this.undo = new Undo();
if (this.sorted) if (this.sorted) {
{ for (final BlockWrapper block : this.solid) {
for (final BlockWrapper block : this.solid)
{
this.setBlock(block); this.setBlock(block);
} }
for (final BlockWrapper block : this.drop) for (final BlockWrapper block : this.drop) {
{
this.setBlock(block); this.setBlock(block);
} }
for (final BlockWrapper block : this.fall) for (final BlockWrapper block : this.fall) {
{
this.setBlock(block); this.setBlock(block);
} }
} } else {
else
{
this.fall.clear(); this.fall.clear();
this.drop.clear(); this.drop.clear();
this.solid.clear(); this.solid.clear();
for (final BlockWrapper block : this.clone) for (final BlockWrapper block : this.clone) {
{ if (this.fallsOff(block.id)) {
if (this.fallsOff(block.id))
{
this.fall.add(block); this.fall.add(block);
} } else if (this.falling(block.id)) {
else if (this.falling(block.id))
{
this.drop.add(block); this.drop.add(block);
} } else if (block.id != 0) {
else if (block.id != 0)
{
this.solid.add(block); this.solid.add(block);
this.setBlock(block); this.setBlock(block);
} }
} }
for (final BlockWrapper block : this.drop) for (final BlockWrapper block : this.drop) {
{
this.setBlock(block); this.setBlock(block);
} }
for (final BlockWrapper block : this.fall) for (final BlockWrapper block : this.fall) {
{
this.setBlock(block); this.setBlock(block);
} }
this.sorted = true; this.sorted = true;
@ -306,10 +210,8 @@ public class StampBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ switch (this.stamp) {
switch (this.stamp)
{
case DEFAULT: case DEFAULT:
this.stamp(v); this.stamp(v);
break; break;
@ -329,20 +231,50 @@ public class StampBrush extends Brush
} }
@Override @Override
protected void powder(final SnipeData v) protected void powder(final SnipeData v) {
{
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public void info(final Message vm) public void info(final Message vm) {
{
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.stamp"; return "voxelsniper.brush.stamp";
} }
/**
* @author Monofraps
*/
protected enum StampType {
NO_AIR, FILL, DEFAULT
}
/**
* @author Voxel
*/
protected class BlockWrapper {
public int id;
public int x;
public int y;
public int z;
public int d;
/**
* @param b
* @param blx
* @param bly
* @param blz
*/
@SuppressWarnings("deprecation")
public BlockWrapper(final AsyncBlock b, final int blx, final int bly, final int blz) {
this.id = b.getTypeId();
this.d = b.getPropertyId();
this.x = blx;
this.y = bly;
this.z = blz;
}
}
} }

Datei anzeigen

@ -1,14 +1,5 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.GZIPInputStream;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.FaweOutputStream;
@ -18,9 +9,10 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import java.io.*;
import java.util.zip.GZIPInputStream;
/** /**
* This is paste only currently. Assumes files exist, and thus has no usefulness until I add in saving stencils later. Uses sniper-exclusive stencil format: 3 * This is paste only currently. Assumes files exist, and thus has no usefulness until I add in saving stencils later. Uses sniper-exclusive stencil format: 3
@ -30,13 +22,12 @@ import org.bukkit.block.Block;
* to be size 1, which in Minecraft is almost definitely true. IF boolean was true, next unsigned byte stores the number of consecutive blocks of the same type, * to be size 1, which in Minecraft is almost definitely true. IF boolean was true, next unsigned byte stores the number of consecutive blocks of the same type,
* up to 256. IF boolean was false, there is no byte here, goes straight to ID and data instead, which applies to just one block. 2 bytes to identify type of * up to 256. IF boolean was false, there is no byte here, goes straight to ID and data instead, which applies to just one block. 2 bytes to identify type of
* block. First byte is ID, second is data. This applies to every one of the line of consecutive blocks if boolean was true. ) * block. First byte is ID, second is data. This applies to every one of the line of consecutive blocks if boolean was true. )
* * <p>
* TODO: Make limit a config option * TODO: Make limit a config option
* *
* @author Gavjenks * @author Gavjenks
*/ */
public class StencilBrush extends Brush public class StencilBrush extends Brush {
{
private byte pasteOption = 1; // 0 = full, 1 = fill, 2 = replace private byte pasteOption = 1; // 0 = full, 1 = fill, 2 = replace
private String filename = "NoFileLoaded"; private String filename = "NoFileLoaded";
private short x; private short x;
@ -54,16 +45,13 @@ public class StencilBrush extends Brush
/** /**
* *
*/ */
public StencilBrush() public StencilBrush() {
{
this.setName("Stencil"); this.setName("Stencil");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void stencilPaste(final SnipeData v) private void stencilPaste(final SnipeData v) {
{ if (this.filename.matches("NoFileLoaded")) {
if (this.filename.matches("NoFileLoaded"))
{
v.sendMessage(ChatColor.RED + "You did not specify a filename. This is required."); v.sendMessage(ChatColor.RED + "You did not specify a filename. This is required.");
return; return;
} }
@ -71,10 +59,8 @@ public class StencilBrush extends Brush
final Undo undo = new Undo(); final Undo undo = new Undo();
final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil"); final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil");
if (file.exists()) if (file.exists()) {
{ try {
try
{
final FaweInputStream in = new FaweInputStream(new DataInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file))))); final FaweInputStream in = new FaweInputStream(new DataInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file)))));
this.x = in.readShort(); this.x = in.readShort();
@ -95,145 +81,109 @@ public class StencilBrush extends Brush
int blockPositionX = getTargetBlock().getX(); int blockPositionX = getTargetBlock().getX();
int blockPositionY = getTargetBlock().getY(); int blockPositionY = getTargetBlock().getY();
int blockPositionZ = getTargetBlock().getZ(); int blockPositionZ = getTargetBlock().getZ();
if (this.pasteOption == 0) if (this.pasteOption == 0) {
{ for (int i = 1; i < numRuns + 1; i++) {
for (int i = 1; i < numRuns + 1; i++) if (in.readBoolean()) {
{
if (in.readBoolean())
{
final int numLoops = in.readByte() + 128; final int numLoops = in.readByte() + 128;
id = in.readVarInt(); id = in.readVarInt();
for (int j = 0; j < numLoops; j++) for (int j = 0; j < numLoops; j++) {
{
undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ));
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id); this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id);
currX++; currX++;
if (currX == this.x - this.xRef) if (currX == this.x - this.xRef) {
{
currX = -this.xRef; currX = -this.xRef;
currZ++; currZ++;
if (currZ == this.z - this.zRef) if (currZ == this.z - this.zRef) {
{
currZ = -this.zRef; currZ = -this.zRef;
currY++; currY++;
} }
} }
} }
} } else {
else
{
undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ));
int combined = in.readVarInt(); int combined = in.readVarInt();
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(combined); this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(combined);
currX++; currX++;
if (currX == this.x - this.xRef) if (currX == this.x - this.xRef) {
{
currX = -this.xRef; currX = -this.xRef;
currZ++; currZ++;
if (currZ == this.z - this.zRef) if (currZ == this.z - this.zRef) {
{
currZ = -this.zRef; currZ = -this.zRef;
currY++; currY++;
} }
} }
} }
} }
} } else if (this.pasteOption == 1) {
else if (this.pasteOption == 1) for (int i = 1; i < numRuns + 1; i++) {
{ if (in.readBoolean()) {
for (int i = 1; i < numRuns + 1; i++)
{
if (in.readBoolean())
{
final int numLoops = in.readByte() + 128; final int numLoops = in.readByte() + 128;
id = (in.readVarInt()); id = (in.readVarInt());
for (int j = 0; j < numLoops; j++) for (int j = 0; j < numLoops; j++) {
{
if (!BlockTypes.getFromStateId(id).getMaterial().isAir() && this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).isEmpty()) if (!BlockTypes.getFromStateId(id).getMaterial().isAir() && this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).isEmpty()) {
{
undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ));
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id); this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id);
} }
currX++; currX++;
if (currX == this.x - this.xRef) if (currX == this.x - this.xRef) {
{
currX = -this.xRef; currX = -this.xRef;
currZ++; currZ++;
if (currZ == this.z - this.zRef) if (currZ == this.z - this.zRef) {
{
currZ = -this.zRef; currZ = -this.zRef;
currY++; currY++;
} }
} }
} }
} } else {
else
{
id = (in.readVarInt()); id = (in.readVarInt());
if (!BlockTypes.getFromStateId(id).getMaterial().isAir() && this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).isEmpty()) if (!BlockTypes.getFromStateId(id).getMaterial().isAir() && this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).isEmpty()) {
{
undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ));
// v.sendMessage("currX:" + currX + " currZ:"+currZ + " currY:" + currY + " id:" + id + " data:" + data); // v.sendMessage("currX:" + currX + " currZ:"+currZ + " currY:" + currY + " id:" + id + " data:" + data);
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id); this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id);
} }
currX++; currX++;
if (currX == this.x - this.xRef) if (currX == this.x - this.xRef) {
{
currX = -this.xRef; currX = -this.xRef;
currZ++; currZ++;
if (currZ == this.z - this.zRef) if (currZ == this.z - this.zRef) {
{
currZ = -this.zRef; currZ = -this.zRef;
currY++; currY++;
} }
} }
} }
} }
} } else { // replace
else for (int i = 1; i < numRuns + 1; i++) {
{ // replace if (in.readBoolean()) {
for (int i = 1; i < numRuns + 1; i++)
{
if (in.readBoolean())
{
final int numLoops = in.readByte() + 128; final int numLoops = in.readByte() + 128;
id = (in.readVarInt()); id = (in.readVarInt());
for (int j = 0; j < (numLoops); j++) for (int j = 0; j < (numLoops); j++) {
{ if (!BlockTypes.getFromStateId(id).getMaterial().isAir()) {
if (!BlockTypes.getFromStateId(id).getMaterial().isAir())
{
undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ));
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id); this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id);
} }
currX++; currX++;
if (currX == this.x - this.xRef) if (currX == this.x - this.xRef) {
{
currX = -this.xRef; currX = -this.xRef;
currZ++; currZ++;
if (currZ == this.z - this.zRef) if (currZ == this.z - this.zRef) {
{
currZ = -this.zRef; currZ = -this.zRef;
currY++; currY++;
} }
} }
} }
} } else {
else
{
id = (in.readVarInt()); id = (in.readVarInt());
if (id != 0) if (id != 0) {
{
undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ)); undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ));
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id); this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id);
} }
currX++; currX++;
if (currX == this.x) if (currX == this.x) {
{
currX = 0; currX = 0;
currZ++; currZ++;
if (currZ == this.z) if (currZ == this.z) {
{
currZ = 0; currZ = 0;
currY++; currY++;
} }
@ -244,26 +194,20 @@ public class StencilBrush extends Brush
in.close(); in.close();
v.owner().storeUndo(undo); v.owner().storeUndo(undo);
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "Something went wrong."); v.sendMessage(ChatColor.RED + "Something went wrong.");
exception.printStackTrace(); exception.printStackTrace();
} }
} } else {
else
{
v.sendMessage(ChatColor.RED + "You need to type a stencil name / your specified stencil does not exist."); v.sendMessage(ChatColor.RED + "You need to type a stencil name / your specified stencil does not exist.");
} }
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void stencilSave(final SnipeData v) private void stencilSave(final SnipeData v) {
{
final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil"); final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil");
try try {
{
this.x = (short) (Math.abs((this.firstPoint[0] - this.secondPoint[0])) + 1); this.x = (short) (Math.abs((this.firstPoint[0] - this.secondPoint[0])) + 1);
this.z = (short) (Math.abs((this.firstPoint[1] - this.secondPoint[1])) + 1); this.z = (short) (Math.abs((this.firstPoint[1] - this.secondPoint[1])) + 1);
this.y = (short) (Math.abs((this.firstPoint[2] - this.secondPoint[2])) + 1); this.y = (short) (Math.abs((this.firstPoint[2] - this.secondPoint[2])) + 1);
@ -271,8 +215,7 @@ public class StencilBrush extends Brush
this.zRef = (short) ((this.firstPoint[1] > this.secondPoint[1]) ? (this.pastePoint[1] - this.secondPoint[1]) : (this.pastePoint[1] - this.firstPoint[1])); this.zRef = (short) ((this.firstPoint[1] > this.secondPoint[1]) ? (this.pastePoint[1] - this.secondPoint[1]) : (this.pastePoint[1] - this.firstPoint[1]));
this.yRef = (short) ((this.firstPoint[2] > this.secondPoint[2]) ? (this.pastePoint[2] - this.secondPoint[2]) : (this.pastePoint[2] - this.firstPoint[2])); this.yRef = (short) ((this.firstPoint[2] > this.secondPoint[2]) ? (this.pastePoint[2] - this.secondPoint[2]) : (this.pastePoint[2] - this.firstPoint[2]));
if ((this.x * this.y * this.z) > 50000) if ((this.x * this.y * this.z) > 50000) {
{
v.sendMessage(ChatColor.AQUA + "Volume exceeds maximum limit."); v.sendMessage(ChatColor.AQUA + "Volume exceeds maximum limit.");
return; return;
} }
@ -299,24 +242,18 @@ public class StencilBrush extends Brush
int thisId; int thisId;
int counter = 0; int counter = 0;
int arrayIndex = 0; int arrayIndex = 0;
for (int y = 0; y < this.y; y++) for (int y = 0; y < this.y; y++) {
{ for (int z = 0; z < this.z; z++) {
for (int z = 0; z < this.z; z++) for (int x = 0; x < this.x; x++) {
{
for (int x = 0; x < this.x; x++)
{
AsyncBlock currentBlock = getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ + z); AsyncBlock currentBlock = getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ + z);
thisId = (currentBlock.getCombinedId()); thisId = (currentBlock.getCombinedId());
if (thisId != lastId || counter == 255) if (thisId != lastId || counter == 255) {
{
blockArray[arrayIndex] = lastId; blockArray[arrayIndex] = lastId;
runSizeArray[arrayIndex] = (byte) (counter - 128); runSizeArray[arrayIndex] = (byte) (counter - 128);
arrayIndex++; arrayIndex++;
counter = 1; counter = 1;
lastId = thisId; lastId = thisId;
} } else {
else
{
counter++; counter++;
lastId = thisId; lastId = thisId;
} }
@ -328,16 +265,12 @@ public class StencilBrush extends Brush
out.writeInt(arrayIndex + 1); out.writeInt(arrayIndex + 1);
// v.sendMessage("number of runs = " + arrayIndex); // v.sendMessage("number of runs = " + arrayIndex);
for (int i = 0; i < arrayIndex + 1; i++) for (int i = 0; i < arrayIndex + 1; i++) {
{ if (runSizeArray[i] > -127) {
if (runSizeArray[i] > -127)
{
out.writeBoolean(true); out.writeBoolean(true);
out.writeByte(runSizeArray[i]); out.writeByte(runSizeArray[i]);
out.writeVarInt(blockArray[i]); out.writeVarInt(blockArray[i]);
} } else {
else
{
out.writeBoolean(false); out.writeBoolean(false);
out.writeVarInt(blockArray[i]); out.writeVarInt(blockArray[i]);
} }
@ -346,45 +279,34 @@ public class StencilBrush extends Brush
v.sendMessage(ChatColor.BLUE + "Saved as '" + this.filename + "'."); v.sendMessage(ChatColor.BLUE + "Saved as '" + this.filename + "'.");
out.close(); out.close();
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "Something went wrong."); v.sendMessage(ChatColor.RED + "Something went wrong.");
exception.printStackTrace(); exception.printStackTrace();
} }
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) { // will be used to copy/save later on?
{ // will be used to copy/save later on? if (this.point == 1) {
if (this.point == 1)
{
this.firstPoint[0] = this.getTargetBlock().getX(); this.firstPoint[0] = this.getTargetBlock().getX();
this.firstPoint[1] = this.getTargetBlock().getZ(); this.firstPoint[1] = this.getTargetBlock().getZ();
this.firstPoint[2] = this.getTargetBlock().getY(); this.firstPoint[2] = this.getTargetBlock().getY();
v.sendMessage(ChatColor.GRAY + "First point"); v.sendMessage(ChatColor.GRAY + "First point");
v.sendMessage("X:" + this.firstPoint[0] + " Z:" + this.firstPoint[1] + " Y:" + this.firstPoint[2]); v.sendMessage("X:" + this.firstPoint[0] + " Z:" + this.firstPoint[1] + " Y:" + this.firstPoint[2]);
this.point = 2; this.point = 2;
} } else if (this.point == 2) {
else if (this.point == 2)
{
this.secondPoint[0] = this.getTargetBlock().getX(); this.secondPoint[0] = this.getTargetBlock().getX();
this.secondPoint[1] = this.getTargetBlock().getZ(); this.secondPoint[1] = this.getTargetBlock().getZ();
this.secondPoint[2] = this.getTargetBlock().getY(); this.secondPoint[2] = this.getTargetBlock().getY();
if ((Math.abs(this.firstPoint[0] - this.secondPoint[0]) * Math.abs(this.firstPoint[1] - this.secondPoint[1]) * Math.abs(this.firstPoint[2] - this.secondPoint[2])) > 5000000) if ((Math.abs(this.firstPoint[0] - this.secondPoint[0]) * Math.abs(this.firstPoint[1] - this.secondPoint[1]) * Math.abs(this.firstPoint[2] - this.secondPoint[2])) > 5000000) {
{
v.sendMessage(ChatColor.DARK_RED + "Area selected is too large. (Limit is 5,000,000 blocks)"); v.sendMessage(ChatColor.DARK_RED + "Area selected is too large. (Limit is 5,000,000 blocks)");
this.point = 1; this.point = 1;
} } else {
else
{
v.sendMessage(ChatColor.GRAY + "Second point"); v.sendMessage(ChatColor.GRAY + "Second point");
v.sendMessage("X:" + this.secondPoint[0] + " Z:" + this.secondPoint[1] + " Y:" + this.secondPoint[2]); v.sendMessage("X:" + this.secondPoint[0] + " Z:" + this.secondPoint[1] + " Y:" + this.secondPoint[2]);
this.point = 3; this.point = 3;
} }
} } else if (this.point == 3) {
else if (this.point == 3)
{
this.pastePoint[0] = this.getTargetBlock().getX(); this.pastePoint[0] = this.getTargetBlock().getX();
this.pastePoint[1] = this.getTargetBlock().getZ(); this.pastePoint[1] = this.getTargetBlock().getZ();
this.pastePoint[2] = this.getTargetBlock().getY(); this.pastePoint[2] = this.getTargetBlock().getY();
@ -397,65 +319,48 @@ public class StencilBrush extends Brush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) { // will be used to paste later on
{ // will be used to paste later on
this.stencilPaste(v); this.stencilPaste(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.custom("File loaded: " + this.filename); vm.custom("File loaded: " + this.filename);
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Stencil brush Parameters:"); v.sendMessage(ChatColor.GOLD + "Stencil brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b schem [optional: 'full' 'fill' or 'replace', with fill as default] [name] -- Loads the specified schematic. Allowed size of schematic is based on rank. Full/fill/replace must come first. Full = paste all blocks, fill = paste only into air blocks, replace = paste full blocks in only, but replace anything in their way."); v.sendMessage(ChatColor.AQUA + "/b schem [optional: 'full' 'fill' or 'replace', with fill as default] [name] -- Loads the specified schematic. Allowed size of schematic is based on rank. Full/fill/replace must come first. Full = paste all blocks, fill = paste only into air blocks, replace = paste full blocks in only, but replace anything in their way.");
v.sendMessage(ChatColor.BLUE + "Size of the stencils you are allowed to paste depends on rank (member / lite, sniper, curator, admin)"); v.sendMessage(ChatColor.BLUE + "Size of the stencils you are allowed to paste depends on rank (member / lite, sniper, curator, admin)");
return; return;
} } else if (par[1].equalsIgnoreCase("full")) {
else if (par[1].equalsIgnoreCase("full"))
{
this.pasteOption = 0; this.pasteOption = 0;
this.pasteParam = 1; this.pasteParam = 1;
} } else if (par[1].equalsIgnoreCase("fill")) {
else if (par[1].equalsIgnoreCase("fill"))
{
this.pasteOption = 1; this.pasteOption = 1;
this.pasteParam = 1; this.pasteParam = 1;
} } else if (par[1].equalsIgnoreCase("replace")) {
else if (par[1].equalsIgnoreCase("replace"))
{
this.pasteOption = 2; this.pasteOption = 2;
this.pasteParam = 1; this.pasteParam = 1;
} }
try try {
{
this.filename = par[1 + this.pasteParam]; this.filename = par[1 + this.pasteParam];
final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil"); final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil");
if (file.exists()) if (file.exists()) {
{
v.sendMessage(ChatColor.RED + "Stencil '" + this.filename + "' exists and was loaded. Make sure you are using powder if you do not want any chance of overwriting the file."); v.sendMessage(ChatColor.RED + "Stencil '" + this.filename + "' exists and was loaded. Make sure you are using powder if you do not want any chance of overwriting the file.");
} } else {
else
{
v.sendMessage(ChatColor.AQUA + "Stencil '" + this.filename + "' does not exist. Ready to be saved to, but cannot be pasted."); v.sendMessage(ChatColor.AQUA + "Stencil '" + this.filename + "' does not exist. Ready to be saved to, but cannot be pasted.");
} }
} } catch (final Exception exception) {
catch (final Exception exception)
{
v.sendMessage(ChatColor.RED + "You need to type a stencil name."); v.sendMessage(ChatColor.RED + "You need to type a stencil name.");
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.stencil"; return "voxelsniper.brush.stencil";
} }
} }

Datei anzeigen

@ -12,8 +12,7 @@ import org.bukkit.util.Vector;
* *
* @author Giltwist * @author Giltwist
*/ */
public class ThreePointCircleBrush extends PerformBrush public class ThreePointCircleBrush extends PerformBrush {
{
private Vector coordsOne; private Vector coordsOne;
private Vector coordsTwo; private Vector coordsTwo;
private Vector coordsThree; private Vector coordsThree;
@ -22,31 +21,22 @@ public class ThreePointCircleBrush extends PerformBrush
/** /**
* Default Constructor. * Default Constructor.
*/ */
public ThreePointCircleBrush() public ThreePointCircleBrush() {
{
this.setName("3-Point Circle"); this.setName("3-Point Circle");
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{ if (this.coordsOne == null) {
if (this.coordsOne == null)
{
this.coordsOne = this.getTargetBlock().getLocation().toVector(); this.coordsOne = this.getTargetBlock().getLocation().toVector();
v.sendMessage(ChatColor.GRAY + "First Corner set."); v.sendMessage(ChatColor.GRAY + "First Corner set.");
} } else if (this.coordsTwo == null) {
else if (this.coordsTwo == null)
{
this.coordsTwo = this.getTargetBlock().getLocation().toVector(); this.coordsTwo = this.getTargetBlock().getLocation().toVector();
v.sendMessage(ChatColor.GRAY + "Second Corner set."); v.sendMessage(ChatColor.GRAY + "Second Corner set.");
} } else if (this.coordsThree == null) {
else if (this.coordsThree == null)
{
this.coordsThree = this.getTargetBlock().getLocation().toVector(); this.coordsThree = this.getTargetBlock().getLocation().toVector();
v.sendMessage(ChatColor.GRAY + "Third Corner set."); v.sendMessage(ChatColor.GRAY + "Third Corner set.");
} } else {
else
{
this.coordsOne = this.getTargetBlock().getLocation().toVector(); this.coordsOne = this.getTargetBlock().getLocation().toVector();
this.coordsTwo = null; this.coordsTwo = null;
this.coordsThree = null; this.coordsThree = null;
@ -55,10 +45,8 @@ public class ThreePointCircleBrush extends PerformBrush
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{ if (this.coordsOne == null || this.coordsTwo == null || this.coordsThree == null) {
if (this.coordsOne == null || this.coordsTwo == null || this.coordsThree == null)
{
return; return;
} }
@ -71,8 +59,7 @@ public class ThreePointCircleBrush extends PerformBrush
vectorThree.subtract(vectorTwo); vectorThree.subtract(vectorTwo);
// Redundant data check // Redundant data check
if (vectorOne.length() == 0 || vectorTwo.length() == 0 || vectorThree.length() == 0 || vectorOne.angle(vectorTwo) == 0 || vectorOne.angle(vectorThree) == 0 || vectorThree.angle(vectorTwo) == 0) if (vectorOne.length() == 0 || vectorTwo.length() == 0 || vectorThree.length() == 0 || vectorOne.angle(vectorTwo) == 0 || vectorOne.angle(vectorThree) == 0 || vectorThree.angle(vectorTwo) == 0) {
{
v.sendMessage(ChatColor.RED + "ERROR: Invalid points, try again."); v.sendMessage(ChatColor.RED + "ERROR: Invalid points, try again.");
this.coordsOne = null; this.coordsOne = null;
@ -117,12 +104,9 @@ public class ThreePointCircleBrush extends PerformBrush
final double radius = circumcenter.distance(new Vector(this.coordsOne.getX(), this.coordsOne.getY(), this.coordsOne.getZ())); final double radius = circumcenter.distance(new Vector(this.coordsOne.getX(), this.coordsOne.getY(), this.coordsOne.getZ()));
final int brushSize = NumberConversions.ceil(radius) + 1; final int brushSize = NumberConversions.ceil(radius) + 1;
for (int x = -brushSize; x <= brushSize; x++) for (int x = -brushSize; x <= brushSize; x++) {
{ for (int y = -brushSize; y <= brushSize; y++) {
for (int y = -brushSize; y <= brushSize; y++) for (int z = -brushSize; z <= brushSize; z++) {
{
for (int z = -brushSize; z <= brushSize; z++)
{
// Calculate distance from center // Calculate distance from center
final double tempDistance = Math.pow(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2), .5); final double tempDistance = Math.pow(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2), .5);
@ -133,8 +117,7 @@ public class ThreePointCircleBrush extends PerformBrush
final double centerConstant = normalVector.getX() * (circumcenter.getX() + x + .5) + normalVector.getY() * (circumcenter.getY() + y + .5) + normalVector.getZ() * (circumcenter.getZ() + z + .5); final double centerConstant = normalVector.getX() * (circumcenter.getX() + x + .5) + normalVector.getY() * (circumcenter.getY() + y + .5) + normalVector.getZ() * (circumcenter.getZ() + z + .5);
// Check if point is within sphere and on plane (some tolerance given) // Check if point is within sphere and on plane (some tolerance given)
if (tempDistance <= radius && (Math.abs(cornerConstant - planeConstant) < this.tolerance.getValue() || Math.abs(centerConstant - planeConstant) < this.tolerance.getValue())) if (tempDistance <= radius && (Math.abs(cornerConstant - planeConstant) < this.tolerance.getValue() || Math.abs(centerConstant - planeConstant) < this.tolerance.getValue())) {
{
this.current.perform(this.clampY(brushCenter.getBlockX() + x, brushCenter.getBlockY() + y, brushCenter.getBlockZ() + z)); this.current.perform(this.clampY(brushCenter.getBlockX() + x, brushCenter.getBlockY() + y, brushCenter.getBlockZ() + z));
} }
@ -153,11 +136,9 @@ public class ThreePointCircleBrush extends PerformBrush
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
switch (this.tolerance) switch (this.tolerance) {
{
case ACCURATE: case ACCURATE:
vm.custom(ChatColor.GOLD + "Mode: Accurate"); vm.custom(ChatColor.GOLD + "Mode: Accurate");
break; break;
@ -175,16 +156,12 @@ public class ThreePointCircleBrush extends PerformBrush
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.YELLOW + "3-Point Circle Brush instructions: Select three corners with the arrow brush, then generate the Circle with the powder brush."); v.sendMessage(ChatColor.YELLOW + "3-Point Circle Brush instructions: Select three corners with the arrow brush, then generate the Circle with the powder brush.");
String toleranceOptions = ""; String toleranceOptions = "";
for (final Tolerance tolerance : Tolerance.values()) for (final Tolerance tolerance : Tolerance.values()) {
{ if (!toleranceOptions.isEmpty()) {
if (!toleranceOptions.isEmpty())
{
toleranceOptions += "|"; toleranceOptions += "|";
} }
toleranceOptions += tolerance.name().toLowerCase(); toleranceOptions += tolerance.name().toLowerCase();
@ -193,46 +170,38 @@ public class ThreePointCircleBrush extends PerformBrush
return; return;
} }
for (int i = 1; i < par.length; i++) for (int i = 1; i < par.length; i++) {
{
final String parameter = par[i].toUpperCase(); final String parameter = par[i].toUpperCase();
try try {
{
this.tolerance = Tolerance.valueOf(parameter); this.tolerance = Tolerance.valueOf(parameter);
v.sendMessage(ChatColor.AQUA + "Brush set to " + this.tolerance.name().toLowerCase() + " tolerance."); v.sendMessage(ChatColor.AQUA + "Brush set to " + this.tolerance.name().toLowerCase() + " tolerance.");
return; return;
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception)
{
v.getVoxelMessage().brushMessage("No such tolerance."); v.getVoxelMessage().brushMessage("No such tolerance.");
} }
} }
} }
@Override
public String getPermissionNode() {
return "voxelsniper.brush.threepointcircle";
}
/** /**
* Enumeration on Tolerance values. * Enumeration on Tolerance values.
* *
* @author MikeMatrix * @author MikeMatrix
*/ */
private enum Tolerance private enum Tolerance {
{
DEFAULT(1000), ACCURATE(10), SMOOTH(2000); DEFAULT(1000), ACCURATE(10), SMOOTH(2000);
private int value; private int value;
Tolerance(final int value) Tolerance(final int value) {
{
this.value = value; this.value = value;
} }
public int getValue() public int getValue() {
{
return this.value; return this.value;
} }
} }
@Override
public String getPermissionNode()
{
return "voxelsniper.brush.threepointcircle";
}
} }

Datei anzeigen

@ -10,9 +10,7 @@ import com.thevoxelbox.voxelsniper.util.UndoDelegate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.TreeType; import org.bukkit.TreeType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
/** /**
@ -20,21 +18,18 @@ import org.bukkit.block.BlockState;
* *
* @author Mick * @author Mick
*/ */
public class TreeSnipeBrush extends Brush public class TreeSnipeBrush extends Brush {
{
private TreeType treeType = TreeType.TREE; private TreeType treeType = TreeType.TREE;
/** /**
* *
*/ */
public TreeSnipeBrush() public TreeSnipeBrush() {
{
this.setName("Tree Snipe"); this.setName("Tree Snipe");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void single(final SnipeData v, AsyncBlock targetBlock) private void single(final SnipeData v, AsyncBlock targetBlock) {
{
UndoDelegate undoDelegate = new UndoDelegate(targetBlock.getWorld()); UndoDelegate undoDelegate = new UndoDelegate(targetBlock.getWorld());
AsyncBlock blockBelow = targetBlock.getRelative(BlockFace.DOWN); AsyncBlock blockBelow = targetBlock.getRelative(BlockFace.DOWN);
AsyncBlockState currentState = blockBelow.getState(); AsyncBlockState currentState = blockBelow.getState();
@ -47,31 +42,23 @@ public class TreeSnipeBrush extends Brush
v.owner().storeUndo(undo); v.owner().storeUndo(undo);
} }
private int getYOffset() private int getYOffset() {
{ for (int i = 1; i < (getTargetBlock().getWorld().getMaxHeight() - 1 - getTargetBlock().getY()); i++) {
for (int i = 1; i < (getTargetBlock().getWorld().getMaxHeight() - 1 - getTargetBlock().getY()); i++) if (Objects.equal(getTargetBlock().getRelative(0, i + 1, 0).getType(), Material.AIR)) {
{
if (Objects.equal(getTargetBlock().getRelative(0, i + 1, 0).getType(), Material.AIR))
{
return i; return i;
} }
} }
return 0; return 0;
} }
private void printTreeType(final Message vm) private void printTreeType(final Message vm) {
{
String printout = ""; String printout = "";
boolean delimiterHelper = true; boolean delimiterHelper = true;
for (final TreeType treeType : TreeType.values()) for (final TreeType treeType : TreeType.values()) {
{ if (delimiterHelper) {
if (delimiterHelper)
{
delimiterHelper = false; delimiterHelper = false;
} } else {
else
{
printout += ", "; printout += ", ";
} }
printout += ((treeType.equals(this.treeType)) ? ChatColor.GRAY + treeType.name().toLowerCase() : ChatColor.DARK_GRAY + treeType.name().toLowerCase()) + ChatColor.WHITE; printout += ((treeType.equals(this.treeType)) ? ChatColor.GRAY + treeType.name().toLowerCase() : ChatColor.DARK_GRAY + treeType.name().toLowerCase()) + ChatColor.WHITE;
@ -81,52 +68,42 @@ public class TreeSnipeBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
AsyncBlock targetBlock = getTargetBlock().getRelative(0, getYOffset(), 0); AsyncBlock targetBlock = getTargetBlock().getRelative(0, getYOffset(), 0);
this.single(v, targetBlock); this.single(v, targetBlock);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.single(v, getTargetBlock()); this.single(v, getTargetBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
this.printTreeType(vm); this.printTreeType(vm);
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++) if (par[i].equalsIgnoreCase("info")) {
{
if (par[i].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Tree snipe brush:"); v.sendMessage(ChatColor.GOLD + "Tree snipe brush:");
v.sendMessage(ChatColor.AQUA + "/b t treetype"); v.sendMessage(ChatColor.AQUA + "/b t treetype");
this.printTreeType(v.getVoxelMessage()); this.printTreeType(v.getVoxelMessage());
return; return;
} }
try try {
{
this.treeType = TreeType.valueOf(par[i].toUpperCase()); this.treeType = TreeType.valueOf(par[i].toUpperCase());
this.printTreeType(v.getVoxelMessage()); this.printTreeType(v.getVoxelMessage());
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception)
{
v.getVoxelMessage().brushMessage("No such tree type."); v.getVoxelMessage().brushMessage("No such tree type.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.treesnipe"; return "voxelsniper.brush.treesnipe";
} }
} }

Datei anzeigen

@ -10,8 +10,7 @@ import org.bukkit.ChatColor;
* *
* @author Giltwist * @author Giltwist
*/ */
public class TriangleBrush extends PerformBrush public class TriangleBrush extends PerformBrush {
{
private double[] coordsOne = new double[3]; // Three corners private double[] coordsOne = new double[3]; // Three corners
private double[] coordsTwo = new double[3]; private double[] coordsTwo = new double[3];
private double[] coordsThree = new double[3]; private double[] coordsThree = new double[3];
@ -25,15 +24,12 @@ public class TriangleBrush extends PerformBrush
/** /**
* *
*/ */
public TriangleBrush() public TriangleBrush() {
{
this.setName("Triangle"); this.setName("Triangle");
} }
private void triangleA(final SnipeData v) private void triangleA(final SnipeData v) {
{ switch (this.cornernumber) {
switch (this.cornernumber)
{
case 1: case 1:
this.coordsOne[0] = this.getTargetBlock().getX() + .5 * this.getTargetBlock().getX() / Math.abs(this.getTargetBlock().getX()); // I hate you sometimes, Notch. Really? Every quadrant is this.coordsOne[0] = this.getTargetBlock().getX() + .5 * this.getTargetBlock().getX() / Math.abs(this.getTargetBlock().getX()); // I hate you sometimes, Notch. Really? Every quadrant is
// different? // different?
@ -65,16 +61,14 @@ public class TriangleBrush extends PerformBrush
} }
private void triangleP(final SnipeData v) private void triangleP(final SnipeData v) {
{
double lengthOne = 0; double lengthOne = 0;
double lengthTwo = 0; double lengthTwo = 0;
double lengthThree = 0; double lengthThree = 0;
double heronBig = 0; double heronBig = 0;
// Calculate slope vectors // Calculate slope vectors
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
{
this.vectorOne[i] = this.coordsTwo[i] - this.coordsOne[i]; this.vectorOne[i] = this.coordsTwo[i] - this.coordsOne[i];
this.vectorTwo[i] = this.coordsThree[i] - this.coordsOne[i]; this.vectorTwo[i] = this.coordsThree[i] - this.coordsOne[i];
this.vectorThree[i] = this.coordsThree[i] - this.coordsTwo[i]; this.vectorThree[i] = this.coordsThree[i] - this.coordsTwo[i];
@ -99,28 +93,22 @@ public class TriangleBrush extends PerformBrush
// Calculate the area of the full triangle // Calculate the area of the full triangle
heronBig = .25 * Math.pow(Math.pow(Math.pow(lengthOne, 2) + Math.pow(lengthTwo, 2) + Math.pow(lengthThree, 2), 2) - 2 * (Math.pow(lengthOne, 4) + Math.pow(lengthTwo, 4) + Math.pow(lengthThree, 4)), .5); heronBig = .25 * Math.pow(Math.pow(Math.pow(lengthOne, 2) + Math.pow(lengthTwo, 2) + Math.pow(lengthThree, 2), 2) - 2 * (Math.pow(lengthOne, 4) + Math.pow(lengthTwo, 4) + Math.pow(lengthThree, 4)), .5);
if (lengthOne == 0 || lengthTwo == 0 || (this.coordsOne[0] == 0 && this.coordsOne[1] == 0 && this.coordsOne[2] == 0) || (this.coordsTwo[0] == 0 && this.coordsTwo[1] == 0 && this.coordsTwo[2] == 0) || (this.coordsThree[0] == 0 && this.coordsThree[1] == 0 && this.coordsThree[2] == 0)) if (lengthOne == 0 || lengthTwo == 0 || (this.coordsOne[0] == 0 && this.coordsOne[1] == 0 && this.coordsOne[2] == 0) || (this.coordsTwo[0] == 0 && this.coordsTwo[1] == 0 && this.coordsTwo[2] == 0) || (this.coordsThree[0] == 0 && this.coordsThree[1] == 0 && this.coordsThree[2] == 0)) {
{
v.sendMessage(ChatColor.RED + "ERROR: Invalid corners, please try again."); v.sendMessage(ChatColor.RED + "ERROR: Invalid corners, please try again.");
} } else {
else
{
// Make the Changes // Make the Changes
final double[] cVectorOne = new double[3]; final double[] cVectorOne = new double[3];
final double[] cVectorTwo = new double[3]; final double[] cVectorTwo = new double[3];
final double[] cVectorThree = new double[3]; final double[] cVectorThree = new double[3];
for (int y = -brushSize; y <= brushSize; y++) for (int y = -brushSize; y <= brushSize; y++) { // X DEPENDENT
{ // X DEPENDENT for (int z = -brushSize; z <= brushSize; z++) {
for (int z = -brushSize; z <= brushSize; z++)
{
this.currentCoords[1] = this.coordsOne[1] + y; this.currentCoords[1] = this.coordsOne[1] + y;
this.currentCoords[2] = this.coordsOne[2] + z; this.currentCoords[2] = this.coordsOne[2] + z;
this.currentCoords[0] = (planeConstant - this.normalVector[1] * this.currentCoords[1] - this.normalVector[2] * this.currentCoords[2]) / this.normalVector[0]; this.currentCoords[0] = (planeConstant - this.normalVector[1] * this.currentCoords[1] - this.normalVector[2] * this.currentCoords[2]) / this.normalVector[0];
// Area of triangle currentcoords, coordsone, coordstwo // Area of triangle currentcoords, coordsone, coordstwo
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
{
cVectorOne[i] = this.coordsTwo[i] - this.coordsOne[i]; cVectorOne[i] = this.coordsTwo[i] - this.coordsOne[i];
cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[i]; cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[i];
cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i];
@ -132,8 +120,7 @@ public class TriangleBrush extends PerformBrush
final double heronOne = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); final double heronOne = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5);
// Area of triangle currentcoords, coordsthree, coordstwo // Area of triangle currentcoords, coordsthree, coordstwo
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
{
cVectorOne[i] = this.coordsTwo[i] - this.coordsThree[i]; cVectorOne[i] = this.coordsTwo[i] - this.coordsThree[i];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i];
cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i];
@ -144,8 +131,7 @@ public class TriangleBrush extends PerformBrush
final double heronTwo = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); final double heronTwo = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5);
// Area of triangle currentcoords, coordsthree, coordsone // Area of triangle currentcoords, coordsthree, coordsone
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
{
cVectorOne[i] = this.coordsOne[i] - this.coordsThree[i]; cVectorOne[i] = this.coordsOne[i] - this.coordsThree[i];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i];
cVectorThree[i] = this.currentCoords[i] - this.coordsOne[i]; cVectorThree[i] = this.currentCoords[i] - this.coordsOne[i];
@ -157,8 +143,7 @@ public class TriangleBrush extends PerformBrush
final double barycentric = (heronOne + heronTwo + heronThree) / heronBig; final double barycentric = (heronOne + heronTwo + heronThree) / heronBig;
if (barycentric <= 1.1) if (barycentric <= 1.1) {
{
this.current.perform(this.clampY((int) this.currentCoords[0], (int) this.currentCoords[1], (int) this.currentCoords[2])); this.current.perform(this.clampY((int) this.currentCoords[0], (int) this.currentCoords[1], (int) this.currentCoords[2]));
@ -167,17 +152,14 @@ public class TriangleBrush extends PerformBrush
} }
} // END X DEPENDENT } // END X DEPENDENT
for (int x = -brushSize; x <= brushSize; x++) for (int x = -brushSize; x <= brushSize; x++) { // Y DEPENDENT
{ // Y DEPENDENT for (int z = -brushSize; z <= brushSize; z++) {
for (int z = -brushSize; z <= brushSize; z++)
{
this.currentCoords[0] = this.coordsOne[0] + x; this.currentCoords[0] = this.coordsOne[0] + x;
this.currentCoords[2] = this.coordsOne[2] + z; this.currentCoords[2] = this.coordsOne[2] + z;
this.currentCoords[1] = (planeConstant - this.normalVector[0] * this.currentCoords[0] - this.normalVector[2] * this.currentCoords[2]) / this.normalVector[1]; this.currentCoords[1] = (planeConstant - this.normalVector[0] * this.currentCoords[0] - this.normalVector[2] * this.currentCoords[2]) / this.normalVector[1];
// Area of triangle currentcoords, coordsone, coordstwo // Area of triangle currentcoords, coordsone, coordstwo
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
{
cVectorOne[i] = this.coordsTwo[i] - this.coordsOne[i]; cVectorOne[i] = this.coordsTwo[i] - this.coordsOne[i];
cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[i]; cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[i];
cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i];
@ -189,8 +171,7 @@ public class TriangleBrush extends PerformBrush
final double heronOne = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); final double heronOne = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5);
// Area of triangle currentcoords, coordsthree, coordstwo // Area of triangle currentcoords, coordsthree, coordstwo
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
{
cVectorOne[i] = this.coordsTwo[i] - this.coordsThree[i]; cVectorOne[i] = this.coordsTwo[i] - this.coordsThree[i];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i];
cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i];
@ -201,8 +182,7 @@ public class TriangleBrush extends PerformBrush
final double heronTwo = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); final double heronTwo = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5);
// Area of triangle currentcoords, coordsthree, coordsone // Area of triangle currentcoords, coordsthree, coordsone
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
{
cVectorOne[i] = this.coordsOne[i] - this.coordsThree[i]; cVectorOne[i] = this.coordsOne[i] - this.coordsThree[i];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i];
cVectorThree[i] = this.currentCoords[i] - this.coordsOne[i]; cVectorThree[i] = this.currentCoords[i] - this.coordsOne[i];
@ -214,8 +194,7 @@ public class TriangleBrush extends PerformBrush
final double barycentric = (heronOne + heronTwo + heronThree) / heronBig; final double barycentric = (heronOne + heronTwo + heronThree) / heronBig;
if (barycentric <= 1.1) if (barycentric <= 1.1) {
{
this.current.perform(this.clampY((int) this.currentCoords[0], (int) this.currentCoords[1], (int) this.currentCoords[2])); this.current.perform(this.clampY((int) this.currentCoords[0], (int) this.currentCoords[1], (int) this.currentCoords[2]));
@ -223,17 +202,14 @@ public class TriangleBrush extends PerformBrush
} }
} // END Y DEPENDENT } // END Y DEPENDENT
for (int x = -brushSize; x <= brushSize; x++) for (int x = -brushSize; x <= brushSize; x++) { // Z DEPENDENT
{ // Z DEPENDENT for (int y = -brushSize; y <= brushSize; y++) {
for (int y = -brushSize; y <= brushSize; y++)
{
this.currentCoords[0] = this.coordsOne[0] + x; this.currentCoords[0] = this.coordsOne[0] + x;
this.currentCoords[1] = this.coordsOne[1] + y; this.currentCoords[1] = this.coordsOne[1] + y;
this.currentCoords[2] = (planeConstant - this.normalVector[0] * this.currentCoords[0] - this.normalVector[1] * this.currentCoords[1]) / this.normalVector[2]; this.currentCoords[2] = (planeConstant - this.normalVector[0] * this.currentCoords[0] - this.normalVector[1] * this.currentCoords[1]) / this.normalVector[2];
// Area of triangle currentcoords, coordsone, coordstwo // Area of triangle currentcoords, coordsone, coordstwo
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
{
cVectorOne[i] = this.coordsTwo[i] - this.coordsOne[i]; cVectorOne[i] = this.coordsTwo[i] - this.coordsOne[i];
cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[i]; cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[i];
cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i];
@ -245,8 +221,7 @@ public class TriangleBrush extends PerformBrush
final double heronOne = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); final double heronOne = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5);
// Area of triangle currentcoords, coordsthree, coordstwo // Area of triangle currentcoords, coordsthree, coordstwo
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
{
cVectorOne[i] = this.coordsTwo[i] - this.coordsThree[i]; cVectorOne[i] = this.coordsTwo[i] - this.coordsThree[i];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i];
cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i]; cVectorThree[i] = this.currentCoords[i] - this.coordsTwo[i];
@ -257,8 +232,7 @@ public class TriangleBrush extends PerformBrush
final double heronTwo = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5); final double heronTwo = .25 * Math.pow(Math.pow(Math.pow(cLengthOne, 2) + Math.pow(cLengthTwo, 2) + Math.pow(cLengthThree, 2), 2) - 2 * (Math.pow(cLengthOne, 4) + Math.pow(cLengthTwo, 4) + Math.pow(cLengthThree, 4)), .5);
// Area of triangle currentcoords, coordsthree, coordsone // Area of triangle currentcoords, coordsthree, coordsone
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
{
cVectorOne[i] = this.coordsOne[i] - this.coordsThree[i]; cVectorOne[i] = this.coordsOne[i] - this.coordsThree[i];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i]; cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[i];
cVectorThree[i] = this.currentCoords[i] - this.coordsOne[i]; cVectorThree[i] = this.currentCoords[i] - this.coordsOne[i];
@ -272,8 +246,7 @@ public class TriangleBrush extends PerformBrush
// VoxelSniper.log.info("Bary: "+barycentric+", hb: "+heronbig+", h1: "+heronone+", h2: "+herontwo+", h3: "+heronthree); // VoxelSniper.log.info("Bary: "+barycentric+", hb: "+heronbig+", h1: "+heronone+", h2: "+herontwo+", h3: "+heronthree);
if (barycentric <= 1.1) if (barycentric <= 1.1) {
{
this.current.perform(this.clampY((int) this.currentCoords[0], (int) this.currentCoords[1], (int) this.currentCoords[2])); this.current.perform(this.clampY((int) this.currentCoords[0], (int) this.currentCoords[1], (int) this.currentCoords[2]));
} }
} }
@ -299,36 +272,30 @@ public class TriangleBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.triangleA(v); this.triangleA(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) { // Add a point
{ // Add a point
this.triangleP(v); this.triangleP(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) { // Make the triangle
{ // Make the triangle
vm.brushName(this.getName()); vm.brushName(this.getName());
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ if (par[1].equalsIgnoreCase("info")) {
if (par[1].equalsIgnoreCase("info"))
{
v.sendMessage(ChatColor.GOLD + "Triangle Brush instructions: Select three corners with the arrow brush, then generate the triangle with the powder brush."); v.sendMessage(ChatColor.GOLD + "Triangle Brush instructions: Select three corners with the arrow brush, then generate the triangle with the powder brush.");
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.triangle"; return "voxelsniper.brush.triangle";
} }
} }

Datei anzeigen

@ -13,8 +13,7 @@ import org.bukkit.ChatColor;
* @author jmck95 Credit to GavJenks for framework and 95 of code. Big Thank you to GavJenks * @author jmck95 Credit to GavJenks for framework and 95 of code. Big Thank you to GavJenks
*/ */
public class UnderlayBrush extends PerformBrush public class UnderlayBrush extends PerformBrush {
{
private static final int DEFAULT_DEPTH = 3; private static final int DEFAULT_DEPTH = 3;
private int depth = DEFAULT_DEPTH; private int depth = DEFAULT_DEPTH;
private boolean allBlocks = false; private boolean allBlocks = false;
@ -22,29 +21,21 @@ public class UnderlayBrush extends PerformBrush
/** /**
* *
*/ */
public UnderlayBrush() public UnderlayBrush() {
{
this.setName("Underlay (Reverse Overlay)"); this.setName("Underlay (Reverse Overlay)");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void underlay(final SnipeData v) private void underlay(final SnipeData v) {
{
final int[][] memory = new int[v.getBrushSize() * 2 + 1][v.getBrushSize() * 2 + 1]; final int[][] memory = new int[v.getBrushSize() * 2 + 1][v.getBrushSize() * 2 + 1];
final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2); final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2);
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
{ for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) for (int y = this.getTargetBlock().getY(); y < this.getTargetBlock().getY() + this.depth; y++) { // start scanning from the height you clicked at
{ if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1) { // if haven't already found the surface in this column
for (int y = this.getTargetBlock().getY(); y < this.getTargetBlock().getY() + this.depth; y++) if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared) { // if inside of the column...
{ // start scanning from the height you clicked at if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1)
{ // if haven't already found the surface in this column
if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared)
{ // if inside of the column...
if (!this.allBlocks)
{ // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
int id = this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z); int id = this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z);
BlockMaterial mat = BlockTypes.get(id).getMaterial(); BlockMaterial mat = BlockTypes.get(id).getMaterial();
if (!mat.isReplacedDuringPlacement() && mat.isFullCube()) { if (!mat.isReplacedDuringPlacement() && mat.isFullCube()) {
@ -60,13 +51,9 @@ public class UnderlayBrush extends PerformBrush
} else { } else {
continue; continue;
} }
} } else {
else for (int d = 0; (d < this.depth); d++) {
{ if (!this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z).isEmpty()) {
for (int d = 0; (d < this.depth); d++)
{
if (!this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z).isEmpty())
{
this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in
// parameters // parameters
memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column.
@ -83,24 +70,17 @@ public class UnderlayBrush extends PerformBrush
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void underlay2(final SnipeData v) private void underlay2(final SnipeData v) {
{
final int[][] memory = new int[v.getBrushSize() * 2 + 1][v.getBrushSize() * 2 + 1]; final int[][] memory = new int[v.getBrushSize() * 2 + 1][v.getBrushSize() * 2 + 1];
final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2); final double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2);
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
{ for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) for (int y = this.getTargetBlock().getY(); y < this.getTargetBlock().getY() + this.depth; y++) { // start scanning from the height you clicked at
{ if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1) { // if haven't already found the surface in this column
for (int y = this.getTargetBlock().getY(); y < this.getTargetBlock().getY() + this.depth; y++) if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared) { // if inside of the column...
{ // start scanning from the height you clicked at
if (memory[x + v.getBrushSize()][z + v.getBrushSize()] != 1)
{ // if haven't already found the surface in this column
if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared)
{ // if inside of the column...
if (!this.allBlocks) if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
{ // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
int id = this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z); int id = this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z);
BlockMaterial mat = BlockTypes.get(id).getMaterial(); BlockMaterial mat = BlockTypes.get(id).getMaterial();
@ -114,11 +94,8 @@ public class UnderlayBrush extends PerformBrush
} else { } else {
continue; continue;
} }
} } else {
else for (int d = -1; (d < this.depth - 1); d++) {
{
for (int d = -1; (d < this.depth - 1); d++)
{
this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y - d, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y - d, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in
// parameters // parameters
memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column.
@ -134,65 +111,50 @@ public class UnderlayBrush extends PerformBrush
} }
@Override @Override
public final void arrow(final SnipeData v) public final void arrow(final SnipeData v) {
{
this.underlay(v); this.underlay(v);
} }
@Override @Override
public final void powder(final SnipeData v) public final void powder(final SnipeData v) {
{
this.underlay2(v); this.underlay2(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public final void parameters(final String[] par, final SnipeData v) public final void parameters(final String[] par, final SnipeData v) {
{ for (int i = 1; i < par.length; i++) {
for (int i = 1; i < par.length; i++) if (par[i].equalsIgnoreCase("info")) {
{
if (par[i].equalsIgnoreCase("info"))
{
v.owner().getPlayer().sendMessage(ChatColor.GOLD + "Reverse Overlay brush parameters:"); v.owner().getPlayer().sendMessage(ChatColor.GOLD + "Reverse Overlay brush parameters:");
v.owner().getPlayer().sendMessage(ChatColor.AQUA + "d[number] (ex: d3) The number of blocks thick to change."); v.owner().getPlayer().sendMessage(ChatColor.AQUA + "d[number] (ex: d3) The number of blocks thick to change.");
v.owner().getPlayer().sendMessage(ChatColor.BLUE + "all (ex: /b reover all) Sets the brush to affect ALL materials"); v.owner().getPlayer().sendMessage(ChatColor.BLUE + "all (ex: /b reover all) Sets the brush to affect ALL materials");
if (this.depth < 1) if (this.depth < 1) {
{
this.depth = 1; this.depth = 1;
} }
return; return;
} }
if (par[i].startsWith("d")) if (par[i].startsWith("d")) {
{
this.depth = Integer.parseInt(par[i].replace("d", "")); this.depth = Integer.parseInt(par[i].replace("d", ""));
v.owner().getPlayer().sendMessage(ChatColor.AQUA + "Depth set to " + this.depth); v.owner().getPlayer().sendMessage(ChatColor.AQUA + "Depth set to " + this.depth);
} } else if (par[i].startsWith("all")) {
else if (par[i].startsWith("all"))
{
this.allBlocks = true; this.allBlocks = true;
v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Will underlay over any block." + this.depth); v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Will underlay over any block." + this.depth);
} } else if (par[i].startsWith("some")) {
else if (par[i].startsWith("some"))
{
this.allBlocks = false; this.allBlocks = false;
v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Will underlay only natural block types." + this.depth); v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Will underlay only natural block types." + this.depth);
} } else {
else
{
v.owner().getPlayer().sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); v.owner().getPlayer().sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
} }
} }
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.underlay"; return "voxelsniper.brush.underlay";
} }
} }

Datei anzeigen

@ -12,26 +12,22 @@ import org.bukkit.block.BlockFace;
* *
* @author Gavjenks * @author Gavjenks
*/ */
public class VoltMeterBrush extends Brush public class VoltMeterBrush extends Brush {
{
/** /**
* *
*/ */
public VoltMeterBrush() public VoltMeterBrush() {
{
this.setName("VoltMeter"); this.setName("VoltMeter");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void data(final SnipeData v) private void data(final SnipeData v) {
{
final AsyncBlock block = this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ()); final AsyncBlock block = this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ());
final int data = block.getPropertyId(); final int data = block.getPropertyId();
v.sendMessage(ChatColor.AQUA + "Blocks until repeater needed: " + data); v.sendMessage(ChatColor.AQUA + "Blocks until repeater needed: " + data);
} }
private void volt(final SnipeData v) private void volt(final SnipeData v) {
{
final Block block = this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ()); final Block block = this.clampY(this.getTargetBlock().getX(), this.getTargetBlock().getY(), this.getTargetBlock().getZ());
final boolean indirect = block.isBlockIndirectlyPowered(); final boolean indirect = block.isBlockIndirectlyPowered();
final boolean direct = block.isBlockPowered(); final boolean direct = block.isBlockPowered();
@ -45,27 +41,23 @@ public class VoltMeterBrush extends Brush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.volt(v); this.volt(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.data(v); this.data(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.brushMessage("Right click with arrow to see if blocks/faces are powered. Powder measures wire current."); vm.brushMessage("Right click with arrow to see if blocks/faces are powered. Powder measures wire current.");
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.voltmeter"; return "voxelsniper.brush.voltmeter";
} }
} }

Datei anzeigen

@ -9,24 +9,18 @@ import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
* *
* @author Piotr * @author Piotr
*/ */
public class VoxelBrush extends PerformBrush public class VoxelBrush extends PerformBrush {
{
/** /**
* *
*/ */
public VoxelBrush() public VoxelBrush() {
{
this.setName("Voxel"); this.setName("Voxel");
} }
private void voxel(final SnipeData v) private void voxel(final SnipeData v) {
{ for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
{ for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--)
{
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--)
{
this.current.perform(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + z, this.getTargetBlock().getZ() + y)); this.current.perform(this.clampY(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + z, this.getTargetBlock().getZ() + y));
} }
} }
@ -35,27 +29,23 @@ public class VoxelBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.voxel(v); this.voxel(v);
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.voxel(v); this.voxel(v);
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.voxel"; return "voxelsniper.brush.voxel";
} }
} }

Datei anzeigen

@ -4,29 +4,23 @@ import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.block.Block;
/** /**
* http://www.voxelwiki.com/minecraft/Voxelsniper#The_Voxel_Disc_Brush * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Voxel_Disc_Brush
* *
* @author Voxel * @author Voxel
*/ */
public class VoxelDiscBrush extends PerformBrush public class VoxelDiscBrush extends PerformBrush {
{
/** /**
* *
*/ */
public VoxelDiscBrush() public VoxelDiscBrush() {
{
this.setName("Voxel Disc"); this.setName("Voxel Disc");
} }
private void disc(final SnipeData v, AsyncBlock targetBlock) private void disc(final SnipeData v, AsyncBlock targetBlock) {
{ for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
{
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--)
{
current.perform(targetBlock.getRelative(x, 0, z)); current.perform(targetBlock.getRelative(x, 0, z));
} }
} }
@ -34,27 +28,23 @@ public class VoxelDiscBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.disc(v, this.getTargetBlock()); this.disc(v, this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.disc(v, this.getLastBlock()); this.disc(v, this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.voxeldisc"; return "voxelsniper.brush.voxeldisc";
} }
} }

Datei anzeigen

@ -11,22 +11,17 @@ import org.bukkit.block.BlockFace;
* *
* @author Voxel * @author Voxel
*/ */
public class VoxelDiscFaceBrush extends PerformBrush public class VoxelDiscFaceBrush extends PerformBrush {
{
/** /**
* *
*/ */
public VoxelDiscFaceBrush() public VoxelDiscFaceBrush() {
{
this.setName("Voxel Disc Face"); this.setName("Voxel Disc Face");
} }
private void disc(final SnipeData v, Block targetBlock) private void disc(final SnipeData v, Block targetBlock) {
{ for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) {
{
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--)
{
this.current.perform(this.clampY(targetBlock.getX() + x, targetBlock.getY(), targetBlock.getZ() + y)); this.current.perform(this.clampY(targetBlock.getX() + x, targetBlock.getY(), targetBlock.getZ() + y));
} }
} }
@ -34,12 +29,9 @@ public class VoxelDiscFaceBrush extends PerformBrush
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void discNS(final SnipeData v, Block targetBlock) private void discNS(final SnipeData v, Block targetBlock) {
{ for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) {
{
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--)
{
this.current.perform(this.clampY(targetBlock.getX() + x, targetBlock.getY() + y, targetBlock.getZ())); this.current.perform(this.clampY(targetBlock.getX() + x, targetBlock.getY() + y, targetBlock.getZ()));
} }
} }
@ -47,12 +39,9 @@ public class VoxelDiscFaceBrush extends PerformBrush
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void discEW(final SnipeData v, Block targetBlock) private void discEW(final SnipeData v, Block targetBlock) {
{ for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) {
{
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--)
{
this.current.perform(this.clampY(targetBlock.getX(), targetBlock.getY() + x, targetBlock.getZ() + y)); this.current.perform(this.clampY(targetBlock.getX(), targetBlock.getY() + x, targetBlock.getZ() + y));
} }
} }
@ -60,14 +49,11 @@ public class VoxelDiscFaceBrush extends PerformBrush
v.owner().storeUndo(this.current.getUndo()); v.owner().storeUndo(this.current.getUndo());
} }
private void pre(final SnipeData v, final BlockFace bf, Block targetBlock) private void pre(final SnipeData v, final BlockFace bf, Block targetBlock) {
{ if (bf == null) {
if (bf == null)
{
return; return;
} }
switch (bf) switch (bf) {
{
case NORTH: case NORTH:
case SOUTH: case SOUTH:
this.discNS(v, targetBlock); this.discNS(v, targetBlock);
@ -89,27 +75,23 @@ public class VoxelDiscFaceBrush extends PerformBrush
} }
@Override @Override
protected final void arrow(final SnipeData v) protected final void arrow(final SnipeData v) {
{
this.pre(v, this.getTargetBlock().getFace(this.getLastBlock()), this.getTargetBlock()); this.pre(v, this.getTargetBlock().getFace(this.getLastBlock()), this.getTargetBlock());
} }
@Override @Override
protected final void powder(final SnipeData v) protected final void powder(final SnipeData v) {
{
this.pre(v, this.getTargetBlock().getFace(this.getLastBlock()), this.getLastBlock()); this.pre(v, this.getTargetBlock().getFace(this.getLastBlock()), this.getLastBlock());
} }
@Override @Override
public final void info(final Message vm) public final void info(final Message vm) {
{
vm.brushName(this.getName()); vm.brushName(this.getName());
vm.size(); vm.size();
} }
@Override @Override
public String getPermissionNode() public String getPermissionNode() {
{
return "voxelsniper.brush.voxeldiscface"; return "voxelsniper.brush.voxeldiscface";
} }
} }

Datei anzeigen

@ -1,18 +1,16 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.util.Vector;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
public class WallSider extends Brush{ public class WallSider extends Brush {
private static String[] facings = new String[] { "north", "east", "south", "west", "relative to player" }; private static String[] facings = new String[]{"north", "east", "south", "west", "relative to player"};
private short c; private short c;
private short d; private short d;
private double e; private double e;
private boolean f; private boolean f;
@ -37,13 +35,12 @@ public class WallSider extends Brush{
n2 += 360.0; n2 += 360.0;
} }
c = ((0.0 >= n2 && n2 < 45.0) ? 2 : ((45.0 >= n2 && n2 < 135.0) ? 3 : ((135.0 >= n2 && n2 < 225.0) ? 0 : ((225.0 >= n2 && n2 < 315.0) ? 1 : ((315.0 >= n2 && n2 < 360.0) ? 2 : -1))))); c = ((0.0 >= n2 && n2 < 45.0) ? 2 : ((45.0 >= n2 && n2 < 135.0) ? 3 : ((135.0 >= n2 && n2 < 225.0) ? 0 : ((225.0 >= n2 && n2 < 315.0) ? 1 : ((315.0 >= n2 && n2 < 360.0) ? 2 : -1)))));
} } else {
else {
c = this.c; c = this.c;
} }
int n3 = c; int n3 = c;
if (b) { if (b) {
n3 = (short)((n3 + 2) % 4); n3 = (short) ((n3 + 2) % 4);
} }
int n4 = 98; int n4 = 98;
if (n3 == 0 || n3 == 2) { if (n3 == 0 || n3 == 2) {
@ -52,8 +49,7 @@ public class WallSider extends Brush{
for (int i = -snipeData.getBrushSize(); i <= snipeData.getBrushSize(); ++i) { for (int i = -snipeData.getBrushSize(); i <= snipeData.getBrushSize(); ++i) {
if (n4 == 97) { if (n4 == 97) {
clone.setX(vector.getX() + i); clone.setX(vector.getX() + i);
} } else {
else {
clone.setZ(vector.getZ() + i); clone.setZ(vector.getZ() + i);
} }
for (int j = -snipeData.getBrushSize(); j <= snipeData.getBrushSize(); ++j) { for (int j = -snipeData.getBrushSize(); j <= snipeData.getBrushSize(); ++j) {
@ -62,8 +58,7 @@ public class WallSider extends Brush{
for (short n5 = 0; n5 < this.d; ++n5) { for (short n5 = 0; n5 < this.d; ++n5) {
if (n4 == 97) { if (n4 == 97) {
clone.setZ(vector.getZ() + ((n3 == 2) ? n5 : (-n5))); clone.setZ(vector.getZ() + ((n3 == 2) ? n5 : (-n5)));
} } else {
else {
clone.setX(vector.getX() + ((n3 == 1) ? n5 : (-n5))); clone.setX(vector.getX() + ((n3 == 1) ? n5 : (-n5)));
} }
final AsyncBlock block2 = this.getWorld().getBlockAt(clone.getBlockX(), clone.getBlockY(), clone.getBlockZ()); final AsyncBlock block2 = this.getWorld().getBlockAt(clone.getBlockX(), clone.getBlockY(), clone.getBlockZ());
@ -73,8 +68,7 @@ public class WallSider extends Brush{
} }
if (n4 == 97) { if (n4 == 97) {
clone.setZ(vector.getZ()); clone.setZ(vector.getZ());
} } else {
else {
clone.setX(vector.getX()); clone.setX(vector.getX());
} }
} }
@ -84,56 +78,51 @@ public class WallSider extends Brush{
@Override @Override
protected final void arrow(final SnipeData snipeData) { protected final void arrow(final SnipeData snipeData) {
this.a(snipeData, this.getTargetBlock(), false); this.a(snipeData, this.getTargetBlock(), false);
} }
@Override @Override
protected final void powder(final SnipeData snipeData) { protected final void powder(final SnipeData snipeData) {
this.a(snipeData, this.getTargetBlock(), true); this.a(snipeData, this.getTargetBlock(), true);
} }
public final void parameters(final String[] array, final SnipeData snipeData) { public final void parameters(final String[] array, final SnipeData snipeData) {
for (int i = 1; i < array.length; ++i) { for (int i = 1; i < array.length; ++i) {
final String lowerCase; final String lowerCase;
if ((lowerCase = array[i].toLowerCase()).startsWith("d")) { if ((lowerCase = array[i].toLowerCase()).startsWith("d")) {
this.d = (short)Integer.parseInt(lowerCase.replace("d", "")); this.d = (short) Integer.parseInt(lowerCase.replace("d", ""));
snipeData.sendMessage(ChatColor.AQUA + "Depth set to " + this.d + " blocks"); snipeData.sendMessage(ChatColor.AQUA + "Depth set to " + this.d + " blocks");
} } else if (lowerCase.startsWith("s")) {
else if (lowerCase.startsWith("s")) { this.c = (short) Integer.parseInt(lowerCase.replace("s", ""));
this.c = (short)Integer.parseInt(lowerCase.replace("s", ""));
if (this.c > 4 || this.c < 0) { if (this.c > 4 || this.c < 0) {
this.c = 4; this.c = 4;
} }
snipeData.sendMessage(ChatColor.AQUA + "Orientation set to " + facings[this.c]); snipeData.sendMessage(ChatColor.AQUA + "Orientation set to " + facings[this.c]);
} } else if (lowerCase.startsWith("true")) {
else if (lowerCase.startsWith("true")) {
this.e = 0.5; this.e = 0.5;
snipeData.sendMessage(ChatColor.AQUA + "True circle mode ON."); snipeData.sendMessage(ChatColor.AQUA + "True circle mode ON.");
} } else if (lowerCase.startsWith("false")) {
else if (lowerCase.startsWith("false")) {
this.e = 0.0; this.e = 0.0;
snipeData.sendMessage(ChatColor.AQUA + "True circle mode OFF."); snipeData.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
} } else if (lowerCase.startsWith("air")) {
else if (lowerCase.startsWith("air")) {
this.g = true; this.g = true;
snipeData.sendMessage(ChatColor.AQUA + "Including air."); snipeData.sendMessage(ChatColor.AQUA + "Including air.");
} } else if (lowerCase.startsWith("mm")) {
else if (lowerCase.startsWith("mm")) {
this.f = true; this.f = true;
snipeData.sendMessage(ChatColor.AQUA + "Replacing block."); snipeData.sendMessage(ChatColor.AQUA + "Replacing block.");
} }
} }
} }
@Override @Override
public String getPermissionNode() { public String getPermissionNode() {
return "voxelsniper.brush.wallsider"; return "voxelsniper.brush.wallsider";
} }
@Override @Override
public void info(Message vm) { public void info(Message vm) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }

Datei anzeigen

@ -35,63 +35,57 @@ import org.bukkit.entity.Player;
/** /**
* @author MikeMatrix * @author MikeMatrix
*/ */
public class WarpBrush extends Brush public class WarpBrush extends Brush {
{
/** /**
* *
*/ */
public WarpBrush() public WarpBrush() {
{
this.setName("Warp"); this.setName("Warp");
} }
@Override
public final void info(final Message vm)
{
vm.brushName(this.getName());
}
@Override
protected final void arrow(final SnipeData v)
{
Player player = v.owner().getPlayer();
Location location = this.getLastBlock().getLocation();
Location playerLocation = player.getLocation();
location.setPitch(playerLocation.getPitch());
location.setYaw(playerLocation.getYaw());
location.setWorld(Bukkit.getWorld(location.getWorld().getName()));
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
player.teleport(location);
}
});
}
@Override
protected final void powder(final SnipeData v)
{
Player player = v.owner().getPlayer();
Location location = this.getLastBlock().getLocation();
Location playerLocation = player.getLocation();
location.setPitch(playerLocation.getPitch());
location.setYaw(playerLocation.getYaw());
location.setWorld(Bukkit.getWorld(location.getWorld().getName()));
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
player.teleport(location);
}
});
}
@Override
public String getPermissionNode()
{
return "voxelsniper.brush.warp";
}
public static Class<?> inject() { public static Class<?> inject() {
return WarpBrush.class; return WarpBrush.class;
} }
@Override
public final void info(final Message vm) {
vm.brushName(this.getName());
}
@Override
protected final void arrow(final SnipeData v) {
Player player = v.owner().getPlayer();
Location location = this.getLastBlock().getLocation();
Location playerLocation = player.getLocation();
location.setPitch(playerLocation.getPitch());
location.setYaw(playerLocation.getYaw());
location.setWorld(Bukkit.getWorld(location.getWorld().getName()));
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
player.teleport(location);
}
});
}
@Override
protected final void powder(final SnipeData v) {
Player player = v.owner().getPlayer();
Location location = this.getLastBlock().getLocation();
Location playerLocation = player.getLocation();
location.setPitch(playerLocation.getPitch());
location.setYaw(playerLocation.getYaw());
location.setWorld(Bukkit.getWorld(location.getWorld().getName()));
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
player.teleport(location);
}
});
}
@Override
public String getPermissionNode() {
return "voxelsniper.brush.warp";
}
} }

Datei anzeigen

@ -8,7 +8,6 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.block.Block;
public class PatternPerformer extends vPerformer { public class PatternPerformer extends vPerformer {
private String info; private String info;
@ -32,7 +31,7 @@ public class PatternPerformer extends vPerformer {
@Override @Override
public void perform(AsyncBlock block) { public void perform(AsyncBlock block) {
BlockVector3 bv = BlockVector3.at(block.getX(), block.getY(), block.getZ()); BlockVector3 bv = BlockVector3.at(block.getX(), block.getY(), block.getZ());
try { try {
pattern.apply(extent, bv, bv); pattern.apply(extent, bv, bv);
} catch (WorldEditException e) { } catch (WorldEditException e) {

Datei anzeigen

@ -1,26 +1,26 @@
/** /**
This file is part of VoxelSniper, licensed under the MIT License (MIT). * This file is part of VoxelSniper, licensed under the MIT License (MIT).
* <p>
Copyright (c) The VoxelBox <http://thevoxelbox.com> * Copyright (c) The VoxelBox <http://thevoxelbox.com>
Copyright (c) contributors * Copyright (c) contributors
* <p>
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* <p>
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* <p>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.thevoxelbox.voxelsniper.brush.perform; package com.thevoxelbox.voxelsniper.brush.perform;
@ -29,31 +29,36 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.Brush; import com.thevoxelbox.voxelsniper.brush.Brush;
import com.thevoxelbox.voxelsniper.event.SniperBrushChangedEvent; import com.thevoxelbox.voxelsniper.event.SniperBrushChangedEvent;
import java.util.Arrays;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import java.util.Arrays;
public abstract class PerformBrush extends Brush implements Performer { public abstract class PerformBrush extends Brush implements Performer {
protected vPerformer current = new pMaterial(); protected vPerformer current = new pMaterial();
public PerformBrush() { public PerformBrush() {
} }
public static Class<?> inject() {
return PerformBrush.class;
}
public vPerformer getCurrentPerformer() { public vPerformer getCurrentPerformer() {
return this.current; return this.current;
} }
public void parse(String[] args, SnipeData v) { public void parse(String[] args, SnipeData v) {
String handle = args[0]; String handle = args[0];
if(PerformerE.has(handle)) { if (PerformerE.has(handle)) {
vPerformer p = PerformerE.getPerformer(handle); vPerformer p = PerformerE.getPerformer(handle);
if(p != null) { if (p != null) {
this.current = p; this.current = p;
SniperBrushChangedEvent event = new SniperBrushChangedEvent(v.owner(), v.owner().getCurrentToolId(), this, this); SniperBrushChangedEvent event = new SniperBrushChangedEvent(v.owner(), v.owner().getCurrentToolId(), this, this);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
this.info(v.getVoxelMessage()); this.info(v.getVoxelMessage());
this.current.info(v.getVoxelMessage()); this.current.info(v.getVoxelMessage());
if(args.length > 1) { if (args.length > 1) {
String[] additionalArguments = (String[])Arrays.copyOfRange(args, 1, args.length); String[] additionalArguments = Arrays.copyOfRange(args, 1, args.length);
this.parameters(this.hackTheArray(additionalArguments), v); this.parameters(this.hackTheArray(additionalArguments), v);
} }
} else { } else {
@ -69,7 +74,7 @@ public abstract class PerformBrush extends Brush implements Performer {
String[] returnValue = new String[args.length + 1]; String[] returnValue = new String[args.length + 1];
int i = 0; int i = 0;
for(int argsLength = args.length; i < argsLength; ++i) { for (int argsLength = args.length; i < argsLength; ++i) {
String arg = args[i]; String arg = args[i];
returnValue[i + 1] = arg; returnValue[i + 1] = arg;
} }
@ -93,8 +98,4 @@ public abstract class PerformBrush extends Brush implements Performer {
public void showInfo(Message vm) { public void showInfo(Message vm) {
this.current.info(vm); this.current.info(vm);
} }
public static Class<?> inject() {
return PerformBrush.class;
}
} }

Datei anzeigen

@ -9,8 +9,7 @@ import com.thevoxelbox.voxelsniper.Message;
/** /**
* @author Voxel * @author Voxel
*/ */
public interface Performer public interface Performer {
{
void parse(String[] args, com.thevoxelbox.voxelsniper.SnipeData v); void parse(String[] args, com.thevoxelbox.voxelsniper.SnipeData v);

Datei anzeigen

@ -4,14 +4,14 @@
*/ */
package com.thevoxelbox.voxelsniper.brush.perform; package com.thevoxelbox.voxelsniper.brush.perform;
import org.bukkit.ChatColor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.ChatColor;
/** /**
* @author Voxel * @author Voxel
*/ */
@ -39,8 +39,7 @@ import org.bukkit.ChatColor;
* Regex to the rescue, am I right? - Giltwist * Regex to the rescue, am I right? - Giltwist
*/ */
public enum PerformerE public enum PerformerE {
{
MATERIAL(pMaterial.class, "m", "material"), MATERIAL(pMaterial.class, "m", "material"),
MATERIAL_NOPHYS(pMaterialNoPhys.class, "mp", "mat-nophys"), MATERIAL_NOPHYS(pMaterialNoPhys.class, "mp", "mat-nophys"),
@ -91,67 +90,16 @@ public enum PerformerE
//COMBO_COMBO_UPDATE( pComboComboUpdate.class, "ccu", "combo-combo-update"), // place combo, replace combo, graphical update //COMBO_COMBO_UPDATE( pComboComboUpdate.class, "ccu", "combo-combo-update"), // place combo, replace combo, graphical update
//COMBO_COMBO_NOPHYS_UPDATE(pComboComboNoPhysUpdate.class, "ccup", "combo-combo-update-nophys"),// place combo, replace combo, graphical update, no physics //COMBO_COMBO_NOPHYS_UPDATE(pComboComboNoPhysUpdate.class, "ccup", "combo-combo-update-nophys"),// place combo, replace combo, graphical update, no physics
private static Map<String, vPerformer> performers;
private static Map<String, String> long_names;
private Class<? extends vPerformer> pclass;
private String short_name;
private String long_name;
public static String performer_list_short = ""; public static String performer_list_short = "";
public static String performer_list_long = ""; public static String performer_list_long = "";
private static Map<String, vPerformer> performers;
private static Map<String, String> long_names;
PerformerE(Class<? extends vPerformer> c, String s, String l) static {
{
pclass = c;
short_name = s;
long_name = l;
}
private vPerformer getPerformer()
{
vPerformer p;
try
{
try
{
p = pclass.getConstructor().newInstance();
return p;
}
catch (InstantiationException | IllegalAccessException | InvocationTargetException | IllegalArgumentException ex)
{
Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex);
}
}
catch (NoSuchMethodException | SecurityException ex)
{
Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
public static vPerformer getPerformer(String s)
{
if (performers.containsKey(s))
{
return performers.get(s);
}
else
{
return performers.get(long_names.get(s));
}
}
public static boolean has(String s)
{
return performers.containsKey(s);
}
static
{
performers = new TreeMap<>(); performers = new TreeMap<>();
long_names = new TreeMap<>(); long_names = new TreeMap<>();
for (PerformerE pe : values()) for (PerformerE pe : values()) {
{
performers.put(pe.short_name, pe.getPerformer()); performers.put(pe.short_name, pe.getPerformer());
long_names.put(pe.long_name, pe.short_name); long_names.put(pe.long_name, pe.short_name);
performer_list_short = performer_list_short + ChatColor.GREEN + pe.short_name + ChatColor.RED + ", "; performer_list_short = performer_list_short + ChatColor.GREEN + pe.short_name + ChatColor.RED + ", ";
@ -160,4 +108,41 @@ public enum PerformerE
performer_list_short = performer_list_short.substring(0, performer_list_short.length() - 2); performer_list_short = performer_list_short.substring(0, performer_list_short.length() - 2);
performer_list_long = performer_list_long.substring(0, performer_list_long.length() - 2); performer_list_long = performer_list_long.substring(0, performer_list_long.length() - 2);
} }
private Class<? extends vPerformer> pclass;
private String short_name;
private String long_name;
PerformerE(Class<? extends vPerformer> c, String s, String l) {
pclass = c;
short_name = s;
long_name = l;
}
public static vPerformer getPerformer(String s) {
if (performers.containsKey(s)) {
return performers.get(s);
} else {
return performers.get(long_names.get(s));
}
}
public static boolean has(String s) {
return performers.containsKey(s);
}
private vPerformer getPerformer() {
vPerformer p;
try {
try {
p = pclass.getConstructor().newInstance();
return p;
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | IllegalArgumentException ex) {
Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (NoSuchMethodException | SecurityException ex) {
Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
} }

Datei anzeigen

@ -10,37 +10,32 @@ import com.thevoxelbox.voxelsniper.Message;
/** /**
* @author Voxel * @author Voxel
*/ */
public class pCombo extends vPerformer public class pCombo extends vPerformer {
{
private int i; private int i;
private int d; private int d;
public pCombo() public pCombo() {
{
name = "Combo"; name = "Combo";
} }
@Override @Override
public void info(Message vm) public void info(Message vm) {
{
vm.performerName(name); vm.performerName(name);
vm.voxel(); vm.voxel();
vm.data(); vm.data();
} }
@Override @Override
public void init(com.thevoxelbox.voxelsniper.SnipeData v) public void init(com.thevoxelbox.voxelsniper.SnipeData v) {
{
w = v.getWorld(); w = v.getWorld();
i = v.getVoxelId(); i = v.getVoxelId();
d = v.getPropertyId(); d = v.getPropertyId();
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void perform(AsyncBlock b) public void perform(AsyncBlock b) {
{
h.put(b); h.put(b);
b.setTypeIdAndPropertyId(i, d, true); b.setTypeIdAndPropertyId(i, d, true);
} }

Datei anzeigen

@ -10,22 +10,19 @@ import com.thevoxelbox.voxelsniper.Message;
/** /**
* @author Voxel * @author Voxel
*/ */
public class pComboCombo extends vPerformer public class pComboCombo extends vPerformer {
{
private int d; private int d;
private int dr; private int dr;
private int i; private int i;
private int ir; private int ir;
public pComboCombo() public pComboCombo() {
{
name = "Combo-Combo"; name = "Combo-Combo";
} }
@Override @Override
public void init(com.thevoxelbox.voxelsniper.SnipeData v) public void init(com.thevoxelbox.voxelsniper.SnipeData v) {
{
w = v.getWorld(); w = v.getWorld();
d = v.getPropertyId(); d = v.getPropertyId();
dr = v.getReplaceData(); dr = v.getReplaceData();
@ -34,8 +31,7 @@ public class pComboCombo extends vPerformer
} }
@Override @Override
public void info(Message vm) public void info(Message vm) {
{
vm.performerName(name); vm.performerName(name);
vm.voxel(); vm.voxel();
vm.replace(); vm.replace();
@ -44,19 +40,16 @@ public class pComboCombo extends vPerformer
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void perform(AsyncBlock b) public void perform(AsyncBlock b) {
{ if (b.getTypeId() == ir && b.getPropertyId() == dr) {
if (b.getTypeId() == ir && b.getPropertyId() == dr)
{
h.put(b); h.put(b);
b.setTypeIdAndPropertyId(i, d, true); b.setTypeIdAndPropertyId(i, d, true);
} }
} }
@Override @Override
public boolean isUsingReplaceMaterial() public boolean isUsingReplaceMaterial() {
{
return true; return true;
} }
} }

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen