3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-02 17:40:09 +01:00
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")
revision = "-${git.head().abbreviatedId}"
parents = git.head().parentIds;
index = -2115; // Offset to match CI
index = -2116; // Offset to match CI
for (; parents != null && !parents.isEmpty(); index++) {
parents = git.getResolve().toCommit(parents.get(0)).getParentIds()
}
@ -59,7 +59,7 @@ if ( project.hasProperty("lzNoVersion") ) { // gradle build -PlzNoVersion
} else {
version = String.format("%s.%s", rootVersion, buildNumber)
}
description = """FastAsyncWorldEdit"""
description = rootProject.name
subprojects {
apply plugin: 'java'
@ -68,8 +68,6 @@ subprojects {
// Enable this requires putting license header files in many, many FAWE files
//apply plugin: 'net.minecrell.licenser'
ext.internalVersion = version
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

Datei anzeigen

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

Datei anzeigen

@ -13,21 +13,18 @@ import java.util.Set;
/**
* Brush registration manager.
*/
public class Brushes
{
public class Brushes {
private Multimap<Class<? extends IBrush>, String> brushes = HashMultimap.create();
/**
* Register a brush for VoxelSniper to be able to use.
*
* @param clazz Brush implementing IBrush interface.
* @param handles Handles under which the brush can be accessed ingame.
* @param clazz Brush implementing IBrush interface.
* @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.");
for (String handle : handles)
{
for (String handle : handles) {
brushes.put(clazz, handle.toLowerCase());
}
}
@ -38,18 +35,14 @@ public class Brushes
* @param handle Case insensitive brush handle
* @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.");
if (!brushes.containsValue(handle.toLowerCase()))
{
if (!brushes.containsValue(handle.toLowerCase())) {
return null;
}
for (Map.Entry<Class<? extends IBrush>, String> entry : brushes.entries())
{
if (entry.getValue().equalsIgnoreCase(handle))
{
for (Map.Entry<Class<? extends IBrush>, String> entry : brushes.entries()) {
if (entry.getValue().equalsIgnoreCase(handle)) {
return entry.getKey();
}
}
@ -59,34 +52,29 @@ public class Brushes
/**
* @return Amount of IBrush classes registered with the system under Sniper visibility.
*/
public int registeredSniperBrushes()
{
public int registeredSniperBrushes() {
return brushes.keySet().size();
}
/**
* @return Amount of handles registered with the system under Sniper visibility.
*/
public int registeredSniperBrushHandles()
{
public int registeredSniperBrushHandles() {
return brushes.size();
}
/**
*
* @param clazz Brush class
* @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 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);
}
}

Datei anzeigen

@ -1,23 +1,19 @@
package com.thevoxelbox.voxelsniper;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.ChatColor;
import org.bukkit.Material;
/**
*
*/
public class Message
{
public class Message {
private static final int BRUSH_SIZE_WARNING_THRESHOLD = 20;
private final SnipeData snipeData;
/**
* @param snipeData
*/
public Message(SnipeData snipeData)
{
public Message(SnipeData snipeData) {
this.snipeData = snipeData;
}
@ -26,8 +22,7 @@ public class Message
*
* @param brushMessage
*/
public void brushMessage(String brushMessage)
{
public void brushMessage(String brushMessage) {
snipeData.sendMessage(ChatColor.LIGHT_PURPLE + brushMessage);
}
@ -36,16 +31,14 @@ public class Message
*
* @param brushName
*/
public void brushName(String brushName)
{
public void brushName(String brushName) {
snipeData.sendMessage(ChatColor.AQUA + "Brush Type: " + ChatColor.LIGHT_PURPLE + brushName);
}
/**
* Display Center Parameter.
*/
public void center()
{
public void center() {
snipeData.sendMessage(ChatColor.DARK_BLUE + "Brush Center: " + ChatColor.DARK_RED + snipeData.getcCen());
}
@ -54,24 +47,21 @@ public class Message
*
* @param message
*/
public void custom(String message)
{
public void custom(String message) {
snipeData.sendMessage(message);
}
/**
* Display data value.
*/
public void data()
{
public void data() {
snipeData.sendMessage(ChatColor.BLUE + "Data Variable: " + ChatColor.DARK_RED + snipeData.getPropertyId());
}
/**
* Display voxel height.
*/
public void height()
{
public void height() {
snipeData.sendMessage(ChatColor.DARK_AQUA + "Brush Height: " + ChatColor.DARK_RED + snipeData.getVoxelHeight());
}
@ -80,8 +70,7 @@ public class Message
*
* @param performerName
*/
public void performerName(String performerName)
{
public void performerName(String performerName) {
this.snipeData.sendMessage(ChatColor.DARK_PURPLE + "Performer: " + ChatColor.DARK_GREEN + performerName);
}
@ -89,27 +78,23 @@ public class Message
* Displaye replace material.
*/
@SuppressWarnings("deprecation")
public void replace()
{
public void replace() {
snipeData.sendMessage(ChatColor.AQUA + "Replace Material: " + BlockTypes.get(snipeData.getReplaceId()));
}
/**
* Display replace data value.
*/
public void replaceData()
{
public void replaceData() {
snipeData.sendMessage(ChatColor.DARK_GRAY + "Replace Data Variable: " + ChatColor.DARK_RED + snipeData.getReplaceData());
}
/**
* Display brush size.
*/
public void size()
{
public void size() {
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!");
}
}
@ -117,24 +102,21 @@ public class 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"));
}
/**
* 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"));
}
/**
* 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());
}
@ -142,22 +124,17 @@ public class Message
* Display voxel type.
*/
@SuppressWarnings("deprecation")
public void voxel()
{
public void voxel() {
snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + BlockTypes.get(snipeData.getVoxelId()));
}
/**
* Display voxel list.
*/
public void voxelList()
{
if (snipeData.getVoxelList().isEmpty())
{
public void voxelList() {
if (snipeData.getVoxelList().isEmpty()) {
snipeData.sendMessage(ChatColor.DARK_GREEN + "No blocks selected!");
}
else
{
} else {
String returnValueBuilder = ChatColor.DARK_GREEN + "Block Types Selected: " + ChatColor.AQUA
+ snipeData.getVoxelList();
snipeData.sendMessage(returnValueBuilder);

Datei anzeigen

@ -4,96 +4,72 @@ import org.bukkit.Art;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Player;
import java.util.Set;
/**
* Painting state change handler.
*
* @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.
*
* @param p
* The player executing the method
* @param auto
* Scroll automatically? If false will use 'choice' to try and set the painting
* @param back
* Scroll in reverse?
* @param choice
* Chosen index to set the painting to
* @param p The player executing the method
* @param auto Scroll automatically? If false will use 'choice' to try and set the painting
* @param back Scroll in reverse?
* @param choice Chosen index to set the painting to
*/
@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();
Chunk paintingChunk = p.getTargetBlock(null, 4).getLocation().getChunk();
Double bestDistanceMatch = 50D;
Painting bestMatch = null;
for (Entity entity : paintingChunk.getEntities())
{
if (entity.getType() == EntityType.PAINTING)
{
for (Entity entity : paintingChunk.getEntities()) {
if (entity.getType() == EntityType.PAINTING) {
Double distance = targetLocation.distanceSquared(entity.getLocation());
if (distance <= 4 && distance < bestDistanceMatch)
{
if (distance <= 4 && distance < bestDistanceMatch) {
bestDistanceMatch = distance;
bestMatch = (Painting) entity;
}
}
}
if (bestMatch != null)
{
if (auto)
{
try
{
if (bestMatch != null) {
if (auto) {
try {
final int i = bestMatch.getArt().getId() + (back ? -1 : 1);
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.");
return;
}
bestMatch.setArt(art);
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.");
}
}
else
{
try
{
} else {
try {
Art art = Art.getById(choice);
bestMatch.setArt(art);
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.");
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -44,25 +44,16 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.*;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.MaskingExtent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.brush.IBrush;
import com.thevoxelbox.voxelsniper.brush.SnipeBrush;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
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.ChatColor;
import org.bukkit.Material;
@ -72,9 +63,13 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.block.Action;
import org.bukkit.material.MaterialData;
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 {
private VoxelSniper plugin;
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 VoxelSniper plugin;
public SniperManager(VoxelSniper plugin)
{
public SniperManager(VoxelSniper plugin) {
this.plugin = plugin;
}
public Sniper getSniperForPlayer(Player player)
{
if (sniperInstances.get(player.getUniqueId()) == null)
{
public Sniper getSniperForPlayer(Player player) {
if (sniperInstances.get(player.getUniqueId()) == null) {
sniperInstances.put(player.getUniqueId(), new Sniper(plugin, player));
}
return sniperInstances.get(player.getUniqueId());

Datei anzeigen

@ -1,34 +1,19 @@
package com.thevoxelbox.voxelsniper;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.BukkitCommand;
import com.boydti.fawe.object.FaweCommand;
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.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.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
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.
*/
public class VoxelSniper extends JavaPlugin
{
public class VoxelSniper extends JavaPlugin {
private static VoxelSniper instance;
private SniperManager sniperManager = new SniperManager(this);
private final VoxelSniperListener voxelSniperListener = new VoxelSniperListener(this);
@ -39,8 +24,7 @@ public class VoxelSniper extends JavaPlugin
*
* @return Brush Manager for current instance.
*/
public Brushes getBrushManager()
{
public Brushes getBrushManager() {
return brushManager;
}
@ -49,8 +33,7 @@ public class VoxelSniper extends JavaPlugin
/**
* @return {@link VoxelSniper}
*/
public static VoxelSniper getInstance()
{
public static VoxelSniper getInstance() {
return VoxelSniper.instance;
}
@ -59,8 +42,7 @@ public class VoxelSniper extends JavaPlugin
*
* @return {@link VoxelSniperConfiguration} object for accessing global VoxelSniper options.
*/
public VoxelSniperConfiguration getVoxelSniperConfiguration()
{
public VoxelSniperConfiguration getVoxelSniperConfiguration() {
return voxelSniperConfiguration;
}
@ -69,20 +51,16 @@ public class VoxelSniper extends JavaPlugin
*
* @return SniperManager
*/
public SniperManager getSniperManager()
{
public SniperManager getSniperManager() {
return sniperManager;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
{
if (sender instanceof Player)
{
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
if (sender instanceof Player) {
String[] arguments = args;
if (arguments == null)
{
if (arguments == null) {
arguments = new String[0];
}
@ -94,8 +72,7 @@ public class VoxelSniper extends JavaPlugin
}
@Override
public void onEnable()
{
public void onEnable() {
VoxelSniper.instance = this;
registerBrushes();
@ -134,14 +111,14 @@ public class VoxelSniper extends JavaPlugin
}
});
} catch (Throwable ignore) {}
} catch (Throwable ignore) {
}
}
/**
* Registers all brushes.
*/
public void registerBrushes()
{
public void registerBrushes() {
brushManager.registerSniperBrush(BallBrush.class, "b", "ball");
brushManager.registerSniperBrush(BiomeBrush.class, "bio", "biome");
brushManager.registerSniperBrush(BlendBallBrush.class, "bb", "blendball");

Datei anzeigen

@ -8,8 +8,7 @@ import java.util.List;
/**
* 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_UNDO_CACHE_SIZE = "undo-cache-size";
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.
*/
public VoxelSniperConfiguration(FileConfiguration configuration)
{
public VoxelSniperConfiguration(FileConfiguration configuration) {
this.configuration = configuration;
}
@ -32,8 +30,7 @@ public class VoxelSniperConfiguration
*
* @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);
}
@ -42,8 +39,7 @@ public class VoxelSniperConfiguration
*
* @param size size of undo cache
*/
public void setUndoCacheSize(int size)
{
public void setUndoCacheSize(int size) {
configuration.set(CONFIG_IDENTIFIER_UNDO_CACHE_SIZE, size);
}
@ -52,8 +48,7 @@ public class VoxelSniperConfiguration
*
* @return maximum size
*/
public int getLiteSniperMaxBrushSize()
{
public int getLiteSniperMaxBrushSize() {
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
*/
public void setLiteSniperMaxBrushSize(int size)
{
public void setLiteSniperMaxBrushSize(int size) {
configuration.set(CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE, size);
}
@ -72,8 +66,7 @@ public class VoxelSniperConfiguration
*
* @return List of restricted Litesniper Items
*/
public List<Integer> getLiteSniperRestrictedItems()
{
public List<Integer> getLiteSniperRestrictedItems() {
return configuration.getIntegerList(CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS);
}
@ -82,8 +75,7 @@ public class VoxelSniperConfiguration
*
* @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.");
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.
*/
public boolean isMessageOnLoginEnabled()
{
public boolean isMessageOnLoginEnabled() {
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
*/
public void setMessageOnLoginEnabled(boolean enabled)
{
public void setMessageOnLoginEnabled(boolean 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.Map;
import java.util.logging.Level;
/**
* @author Voxel
*/
public class VoxelSniperListener implements Listener
{
public class VoxelSniperListener implements Listener {
private static final String SNIPER_PERMISSION = "voxelsniper.sniper";
private final VoxelSniper plugin;
@ -31,8 +29,7 @@ public class VoxelSniperListener implements Listener
/**
* @param plugin
*/
public VoxelSniperListener(final VoxelSniper plugin)
{
public VoxelSniperListener(final VoxelSniper plugin) {
this.plugin = plugin;
addCommand(new VoxelBrushCommand(plugin));
addCommand(new VoxelBrushToolCommand(plugin));
@ -53,8 +50,7 @@ public class VoxelSniperListener implements Listener
addCommand(new VoxelVoxelCommand(plugin));
}
private void addCommand(final VoxelCommand command)
{
private void addCommand(final VoxelCommand command) {
this.commands.put(command.getIdentifier().toLowerCase(), command);
}
@ -64,16 +60,13 @@ public class VoxelSniperListener implements Listener
* @param command
* @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());
if (found == null)
{
if (found == null) {
return false;
}
if (!hasPermission(found, player))
{
if (!hasPermission(found, player)) {
player.sendMessage(ChatColor.RED + "Insufficient Permissions.");
return true;
}
@ -111,20 +104,14 @@ public class VoxelSniperListener implements Listener
return true;
}
private boolean hasPermission(final VoxelCommand command, final Player player)
{
if (command == null || player == null)
{
private boolean hasPermission(final VoxelCommand command, final Player player) {
if (command == null || player == null) {
// Just a usual check for nulls
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
return true;
}
else
{
} else {
// Should utilize Vault for permission checks if available
return player.hasPermission(command.getPermission());
}
@ -134,25 +121,19 @@ public class VoxelSniperListener implements Listener
* @param event
*/
@EventHandler(ignoreCancelled = false)
public final void onPlayerInteract(final PlayerInteractEvent event)
{
public final void onPlayerInteract(final PlayerInteractEvent event) {
Player player = event.getPlayer();
if (!player.hasPermission(SNIPER_PERMISSION))
{
if (!player.hasPermission(SNIPER_PERMISSION)) {
return;
}
try
{
try {
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);
}
}
catch (final Throwable ignored)
{
} catch (final Throwable ignored) {
ignored.printStackTrace();
}
}
@ -161,13 +142,11 @@ public class VoxelSniperListener implements Listener
* @param event
*/
@EventHandler
public final void onPlayerJoin(final PlayerJoinEvent event)
{
public final void onPlayerJoin(final PlayerJoinEvent event) {
Player player = event.getPlayer();
Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player);
if (player.hasPermission(SNIPER_PERMISSION) && plugin.getVoxelSniperConfiguration().isMessageOnLoginEnabled())
{
if (player.hasPermission(SNIPER_PERMISSION) && plugin.getVoxelSniperConfiguration().isMessageOnLoginEnabled()) {
sniper.displayInfo();
}
}

Datei anzeigen

@ -4,9 +4,7 @@ import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
/**
* A brush that creates a solid ball.
@ -14,8 +12,7 @@ import org.bukkit.block.Block;
*
* @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 int TRUE_CIRCLE_OFF_VALUE = 0;
private double trueCircle = 0;
@ -23,13 +20,11 @@ public class BallBrush extends PerformBrush
/**
*
*/
public BallBrush()
{
public BallBrush() {
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 double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
@ -38,8 +33,7 @@ public class BallBrush extends PerformBrush
int blockPositionZ = targetBlock.getZ();
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);
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));
for (int x = 1; x <= brushSize; x++)
{
for (int x = 1; x <= brushSize; x++) {
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));
@ -69,10 +61,8 @@ public class BallBrush extends PerformBrush
this.current.perform(this.clampY(blockPositionX, blockPositionY - z, blockPositionZ - x));
}
for (int y = 1; y <= brushSize; y++)
{
if ((xSquared + Math.pow(y, 2) + zSquared) <= brushSizeSquared)
{
for (int y = 1; y <= brushSize; y++) {
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));
@ -90,57 +80,44 @@ public class BallBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.ball(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.ball(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
final String parameter = par[i];
if (parameter.equalsIgnoreCase("info"))
{
if (parameter.equalsIgnoreCase("info")) {
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)");
return;
}
else if (parameter.startsWith("true"))
{
} else if (parameter.startsWith("true")) {
this.trueCircle = TRUE_CIRCLE_ON_VALUE;
v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
}
else if (parameter.startsWith("false"))
{
} else if (parameter.startsWith("false")) {
this.trueCircle = TRUE_CIRCLE_OFF_VALUE;
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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;
/**
*
*/
public BiomeBrush()
{
public BiomeBrush() {
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 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);
for (int z = -brushSize; z <= brushSize; z++)
{
if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared)
{
for (int z = -brushSize; z <= brushSize; z++) {
if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared) {
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 highChunkZ = (block1.getZ() >= block2.getZ()) ? block1.getChunk().getZ() : block2.getChunk().getZ();
for (int x = lowChunkX; x <= highChunkX; x++)
{
for (int z = lowChunkZ; z <= highChunkZ; z++)
{
for (int x = lowChunkX; x <= highChunkX; x++) {
for (int z = lowChunkZ; z <= highChunkZ; z++) {
this.getWorld().refreshChunk(x, z);
}
}
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.biome(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.biome(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
vm.custom(ChatColor.GOLD + "Currently selected biome type: " + ChatColor.DARK_GREEN + this.selectedBiome.name());
}
@Override
public final void parameters(final String[] args, final SnipeData v)
{
if (args[1].equalsIgnoreCase("info"))
{
public final void parameters(final String[] args, final SnipeData v) {
if (args[1].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Biome Brush Parameters:");
StringBuilder availableBiomes = new StringBuilder();
for (final Biome biome : Biome.values())
{
if (availableBiomes.length() == 0)
{
for (final Biome biome : Biome.values()) {
if (availableBiomes.length() == 0) {
availableBiomes = new StringBuilder(ChatColor.DARK_GREEN + biome.name());
continue;
}
availableBiomes.append(ChatColor.RED + ", " + ChatColor.DARK_GREEN)
.append(biome.name());
.append(biome.name());
}
v.sendMessage(ChatColor.DARK_BLUE + "Available biomes: " + availableBiomes);
}
else
{
} else {
// allows biome names with spaces in their name
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]);
}
for (final Biome biome : Biome.values())
{
if (biome.name().equalsIgnoreCase(biomeName.toString()))
{
for (final Biome biome : Biome.values()) {
if (biome.name().equalsIgnoreCase(biomeName.toString())) {
this.selectedBiome = biome;
break;
}
@ -120,8 +100,7 @@ public class BiomeBrush extends Brush
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.Material;
/**
* 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");
}
@SuppressWarnings("deprecation")
@Override
protected final void blend(final SnipeData v)
{
@Override
protected final void blend(final SnipeData v) {
final int brushSize = v.getBrushSize();
final int brushSizeDoubled = 2 * brushSize;
// 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];
// Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++)
{
for (int y = 0; y <= 2 * (brushSize + 1); y++)
{
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
for (int x = 0; x <= 2 * (brushSize + 1); x++) {
for (int y = 0; y <= 2 * (brushSize + 1); y++) {
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);
}
}
}
// Log current materials into newmats
for (int x = 0; x <= brushSizeDoubled; x++)
{
for (int y = 0; y <= brushSizeDoubled; y++)
{
for (int x = 0; x <= brushSizeDoubled; x++) {
for (int y = 0; y <= brushSizeDoubled; y++) {
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
brushSizeDoubled + 1);
brushSizeDoubled + 1);
}
}
// Blend materials
for (int x = 0; x <= brushSizeDoubled; x++)
{
for (int y = 0; y <= brushSizeDoubled; y++)
{
for (int z = 0; z <= brushSizeDoubled; z++)
{
for (int x = 0; x <= brushSizeDoubled; x++) {
for (int y = 0; y <= brushSizeDoubled; y++) {
for (int z = 0; z <= brushSizeDoubled; z++) {
final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block
int modeMatCount = 0;
int modeMatId = 0;
boolean tiecheck = true;
for (int m = -1; m <= 1; m++)
{
for (int n = -1; n <= 1; n++)
{
for (int o = -1; o <= 1; o++)
{
if (!(m == 0 && n == 0 && o == 0))
{
for (int m = -1; m <= 1; m++) {
for (int n = -1; n <= 1; n++) {
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]]++;
}
}
@ -81,28 +64,23 @@ public class BlendBallBrush extends BlendBrushBase
}
// Find most common neighboring material.
for (BlockType type : BlockTypes.values)
{
for (BlockType type : BlockTypes.values) {
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];
modeMatId = i;
}
}
// 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);
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;
}
}
// Record most common neighbor material for this block
if (tiecheck)
{
if (tiecheck) {
newMaterials[x][y][z] = modeMatId;
}
}
@ -113,22 +91,16 @@ public class BlendBallBrush extends BlendBrushBase
final double rSquared = Math.pow(brushSize + 1, 2);
// 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);
for (int y = 0; y <= brushSizeDoubled; y++)
{
for (int y = 0; y <= brushSizeDoubled; y++) {
final double ySquared = Math.pow(y - brushSize - 1, 2);
for (int z = brushSizeDoubled; z >= 0; z--)
{
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])
{
for (int z = brushSizeDoubled; z >= 0; z--) {
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]) {
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]);
@ -141,10 +113,8 @@ public class BlendBallBrush extends BlendBrushBase
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
if (par[1].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
if (par[1].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Blend Ball Parameters:");
v.sendMessage(ChatColor.AQUA + "/b bb water -- toggle include or exclude (default: exclude) water");
return;
@ -154,8 +124,7 @@ public class BlendBallBrush extends BlendBrushBase
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.blendball";
}
}

Datei anzeigen

@ -1,20 +1,14 @@
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.SnipeData;
import org.bukkit.ChatColor;
import org.bukkit.Material;
/**
* @author Monofraps
*/
@SuppressWarnings("deprecation")
public abstract class BlendBrushBase extends Brush
{
public abstract class BlendBrushBase extends Brush {
protected boolean excludeAir = true;
protected boolean excludeWater = true;
@ -24,22 +18,19 @@ public abstract class BlendBrushBase extends Brush
protected abstract void blend(final SnipeData v);
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.excludeAir = false;
this.blend(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.excludeAir = true;
this.blend(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
vm.voxel();
@ -47,12 +38,9 @@ public abstract class BlendBrushBase extends Brush
}
@Override
public void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; ++i)
{
if (par[i].equalsIgnoreCase("water"))
{
public void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; ++i) {
if (par[i].equalsIgnoreCase("water")) {
this.excludeWater = !this.excludeWater;
v.sendMessage(ChatColor.AQUA + "Water Mode: " + (this.excludeWater ? "exclude" : "include"));
}
@ -62,32 +50,28 @@ public abstract class BlendBrushBase extends Brush
/**
* @return
*/
protected final boolean isExcludeAir()
{
protected final boolean isExcludeAir() {
return excludeAir;
}
/**
* @param excludeAir
*/
protected final void setExcludeAir(boolean excludeAir)
{
protected final void setExcludeAir(boolean excludeAir) {
this.excludeAir = excludeAir;
}
/**
* @return
*/
protected final boolean isExcludeWater()
{
protected final boolean isExcludeWater() {
return excludeWater;
}
/**
* @param excludeWater
*/
protected final void setExcludeWater(boolean excludeWater)
{
protected final void setExcludeWater(boolean 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.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.Material;
/**
* 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");
}
@SuppressWarnings("deprecation")
@Override
protected final void blend(final SnipeData v)
{
@Override
protected final void blend(final SnipeData v) {
final int brushSize = v.getBrushSize();
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[][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Array that holds the blended materials
// Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++)
{
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
for (int x = 0; x <= 2 * (brushSize + 1); x++) {
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);
}
}
// 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);
}
// Blend materials
for (int x = 0; x <= brushSizeDoubled; x++)
{
for (int z = 0; z <= brushSizeDoubled; z++)
{
for (int x = 0; x <= brushSizeDoubled; x++) {
for (int z = 0; z <= brushSizeDoubled; z++) {
final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block
int modeMatCount = 0;
int modeMatId = 0;
boolean tiecheck = true;
for (int m = -1; m <= 1; m++)
{
for (int n = -1; n <= 1; n++)
{
if (!(m == 0 && n == 0))
{
for (int m = -1; m <= 1; m++) {
for (int n = -1; n <= 1; n++) {
if (!(m == 0 && n == 0)) {
materialFrequency[oldMaterials[x + 1 + m][z + 1 + n]]++;
}
}
}
// Find most common neighboring material.
for (BlockType type : BlockTypes.values)
{
for (BlockType type : BlockTypes.values) {
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];
modeMatId = i;
}
}
// 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);
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;
}
}
// Record most common neighbor material for this block
if (tiecheck)
{
if (tiecheck) {
newMaterials[x][z] = modeMatId;
}
}
@ -98,18 +80,13 @@ public class BlendDiscBrush extends BlendBrushBase
final double rSquared = Math.pow(brushSize + 1, 2);
// 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);
for (int z = brushSizeDoubled; z >= 0; z--)
{
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])
{
for (int z = brushSizeDoubled; z >= 0; z--) {
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]) {
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]);
@ -121,10 +98,8 @@ public class BlendDiscBrush extends BlendBrushBase
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
if (par[1].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
if (par[1].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Blend Disc Parameters:");
v.sendMessage(ChatColor.AQUA + "/b bd water -- toggle include or exclude (default) water");
return;
@ -134,8 +109,7 @@ public class BlendDiscBrush extends BlendBrushBase
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.Material;
/**
* 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");
}
@SuppressWarnings("deprecation")
@Override
protected final void blend(final SnipeData v)
{
@Override
protected final void blend(final SnipeData v) {
final int brushSize = v.getBrushSize();
final int brushSizeDoubled = 2 * brushSize;
// 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];
// Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++)
{
for (int y = 0; y <= 2 * (brushSize + 1); y++)
{
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
for (int x = 0; x <= 2 * (brushSize + 1); x++) {
for (int y = 0; y <= 2 * (brushSize + 1); y++) {
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);
}
}
}
// Log current materials into newmats
for (int x = 0; x <= brushSizeDoubled; x++)
{
for (int y = 0; y <= brushSizeDoubled; y++)
{
for (int x = 0; x <= brushSizeDoubled; x++) {
for (int y = 0; y <= brushSizeDoubled; y++) {
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
brushSizeDoubled + 1);
brushSizeDoubled + 1);
}
}
// Blend materials
for (int x = 0; x <= brushSizeDoubled; x++)
{
for (int y = 0; y <= brushSizeDoubled; y++)
{
for (int z = 0; z <= brushSizeDoubled; z++)
{
for (int x = 0; x <= brushSizeDoubled; x++) {
for (int y = 0; y <= brushSizeDoubled; y++) {
for (int z = 0; z <= brushSizeDoubled; z++) {
final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block
int modeMatCount = 0;
int modeMatId = 0;
boolean tiecheck = true;
for (int m = -1; m <= 1; m++)
{
for (int n = -1; n <= 1; n++)
{
for (int o = -1; o <= 1; o++)
{
if (!(m == 0 && n == 0 && o == 0))
{
for (int m = -1; m <= 1; m++) {
for (int n = -1; n <= 1; n++) {
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]]++;
}
}
@ -81,28 +64,23 @@ public class BlendVoxelBrush extends BlendBrushBase
}
// Find most common neighboring material.
for (BlockType type : BlockTypes.values)
{
for (BlockType type : BlockTypes.values) {
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];
modeMatId = i;
}
}
// 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);
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;
}
}
// Record most common neighbor material for this block
if (tiecheck)
{
if (tiecheck) {
newMaterials[x][y][z] = modeMatId;
}
}
@ -112,16 +90,11 @@ public class BlendVoxelBrush extends BlendBrushBase
final Undo undo = new Undo();
// Make the changes
for (int x = brushSizeDoubled; x >= 0; x--)
{
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())))
{
if (this.getBlockIdAt(this.getTargetBlock().getX() - brushSize + x, this.getTargetBlock().getY() - brushSize + y, this.getTargetBlock().getZ() - brushSize + z) != newMaterials[x][y][z])
{
for (int x = brushSizeDoubled; x >= 0; x--) {
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()))) {
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));
}
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
public final void parameters(final String[] par, final SnipeData v)
{
if (par[1].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
if (par[1].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Blend Voxel Parameters:");
v.sendMessage(ChatColor.AQUA + "/b bv water -- toggle include or exclude (default) water");
return;
@ -147,8 +118,7 @@ public class BlendVoxelBrush extends BlendBrushBase
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.Material;
/**
* 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");
}
@SuppressWarnings("deprecation")
@Override
protected final void blend(final SnipeData v)
{
@Override
protected final void blend(final SnipeData v) {
final int brushSize = v.getBrushSize();
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[][] newMaterials = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Array that holds the blended materials
// Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++)
{
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
for (int x = 0; x <= 2 * (brushSize + 1); x++) {
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);
}
}
// 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);
}
// Blend materials
for (int x = 0; x <= brushSizeDoubled; x++)
{
for (int z = 0; z <= brushSizeDoubled; z++)
{
for (int x = 0; x <= brushSizeDoubled; x++) {
for (int z = 0; z <= brushSizeDoubled; z++) {
final int[] materialFrequency = new int[BlockTypes.size()]; // Array that tracks frequency of materials neighboring given block
int modeMatCount = 0;
int modeMatId = 0;
boolean tiecheck = true;
for (int m = -1; m <= 1; m++)
{
for (int n = -1; n <= 1; n++)
{
if (!(m == 0 && n == 0))
{
for (int m = -1; m <= 1; m++) {
for (int n = -1; n <= 1; n++) {
if (!(m == 0 && n == 0)) {
materialFrequency[oldMaterials[x + 1 + m][z + 1 + n]]++;
}
}
}
// Find most common neighboring material.
for (BlockType type : BlockTypes.values)
{
for (BlockType type : BlockTypes.values) {
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];
modeMatId = i;
}
}
// 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);
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;
}
}
// Record most common neighbor material for this block
if (tiecheck)
{
if (tiecheck) {
newMaterials[x][z] = modeMatId;
}
}
@ -97,14 +79,10 @@ public class BlendVoxelDiscBrush extends BlendBrushBase
final Undo undo = new Undo();
// Make the changes
for (int x = brushSizeDoubled; x >= 0; x--)
{
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])
{
for (int x = brushSizeDoubled; x >= 0; x--) {
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]) {
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]);
@ -117,10 +95,8 @@ public class BlendVoxelDiscBrush extends BlendBrushBase
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
if (par[1].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
if (par[1].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Blend Voxel Disc Parameters:");
v.sendMessage(ChatColor.AQUA + "/b bvd water -- toggle include or exclude (default) water");
return;
@ -130,8 +106,7 @@ public class BlendVoxelDiscBrush extends BlendBrushBase
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.blendvoxeldisc";
}
}

Datei anzeigen

@ -1,20 +1,18 @@
package com.thevoxelbox.voxelsniper.brush;
import java.util.Random;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import java.util.Random;
/**
* http://www.voxelwiki.com/minecraft/Voxelsniper#The_Blob_Brush
*
* @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_MIN = 1;
private static final int GROW_PERCENT_MAX = 9999;
@ -25,22 +23,18 @@ public class BlobBrush extends PerformBrush
/**
*
*/
public BlobBrush()
{
public BlobBrush() {
this.setName("Blob");
}
private void checkValidGrowPercent(final SnipeData v)
{
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX)
{
private void checkValidGrowPercent(final SnipeData v) {
if (this.growPercent < GROW_PERCENT_MIN || this.growPercent > GROW_PERCENT_MAX) {
this.growPercent = GROW_PERCENT_DEFAULT;
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 brushSizeDoubled = 2 * brushSize;
final int[][][] splat = new int[brushSizeDoubled + 1][brushSizeDoubled + 1][brushSizeDoubled + 1];
@ -49,18 +43,12 @@ public class BlobBrush extends PerformBrush
this.checkValidGrowPercent(v);
// Seed the array
for (int x = brushSizeDoubled; x >= 0; x--)
{
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 x = brushSizeDoubled; x >= 0; x--) {
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) {
splat[x][y][z] = 0;
}
else
{
} else {
splat[x][y][z] = 1;
}
}
@ -68,46 +56,34 @@ public class BlobBrush extends PerformBrush
}
// Grow the seed
for (int r = 0; r < brushSize; r++)
{
for (int x = brushSizeDoubled; x >= 0; x--)
{
for (int y = brushSizeDoubled; y >= 0; y--)
{
for (int z = brushSizeDoubled; z >= 0; z--)
{
for (int r = 0; r < brushSize; r++) {
for (int x = brushSizeDoubled; x >= 0; x--) {
for (int y = brushSizeDoubled; y >= 0; y--) {
for (int z = brushSizeDoubled; z >= 0; z--) {
tempSplat[x][y][z] = splat[x][y][z];
double growCheck = 0;
if (splat[x][y][z] == 1)
{
if (x != 0 && splat[x - 1][y][z] == 0)
{
if (splat[x][y][z] == 1) {
if (x != 0 && splat[x - 1][y][z] == 0) {
growCheck++;
}
if (y != 0 && splat[x][y - 1][z] == 0)
{
if (y != 0 && splat[x][y - 1][z] == 0) {
growCheck++;
}
if (z != 0 && splat[x][y][z - 1] == 0)
{
if (z != 0 && splat[x][y][z - 1] == 0) {
growCheck++;
}
if (x != 2 * brushSize && splat[x + 1][y][z] == 0)
{
if (x != 2 * brushSize && splat[x + 1][y][z] == 0) {
growCheck++;
}
if (y != 2 * brushSize && splat[x][y + 1][z] == 0)
{
if (y != 2 * brushSize && splat[x][y + 1][z] == 0) {
growCheck++;
}
if (z != 2 * brushSize && splat[x][y][z + 1] == 0)
{
if (z != 2 * brushSize && splat[x][y][z + 1] == 0) {
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
}
}
@ -116,10 +92,8 @@ public class BlobBrush extends PerformBrush
// shouldn't this just be splat = tempsplat;? -Gavjenks
// integrate tempsplat back into splat at end of iteration
for (int x = brushSizeDoubled; x >= 0; x--)
{
for (int y = brushSizeDoubled; y >= 0; y--)
{
for (int x = brushSizeDoubled; x >= 0; x--) {
for (int y = brushSizeDoubled; y >= 0; y--) {
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);
// 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);
for (int y = brushSizeDoubled; y >= 0; y--)
{
for (int y = brushSizeDoubled; y >= 0; y--) {
final double ySquared = Math.pow(y - brushSize - 1, 2);
for (int z = brushSizeDoubled; z >= 0; z--)
{
if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared)
{
for (int z = brushSizeDoubled; z >= 0; z--) {
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));
}
}
@ -149,8 +119,7 @@ public class BlobBrush extends PerformBrush
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 brushSizeDoubled = 2 * brushSize;
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;
// 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 y = brushSizeDoubled; y >= 0; y--)
{
for (int z = brushSizeDoubled; z >= 0; z--)
{
for (int x = brushSizeDoubled; x >= 0; x--) {
for (int y = brushSizeDoubled; y >= 0; y--) {
for (int z = brushSizeDoubled; z >= 0; z--) {
tempSplat[x][y][z] = splat[x][y][z];
int growCheck = 0;
if (splat[x][y][z] == 0)
{
if (x != 0 && splat[x - 1][y][z] == 1)
{
if (splat[x][y][z] == 0) {
if (x != 0 && splat[x - 1][y][z] == 1) {
growCheck++;
}
if (y != 0 && splat[x][y - 1][z] == 1)
{
if (y != 0 && splat[x][y - 1][z] == 1) {
growCheck++;
}
if (z != 0 && splat[x][y][z - 1] == 1)
{
if (z != 0 && splat[x][y][z - 1] == 1) {
growCheck++;
}
if (x != 2 * brushSize && splat[x + 1][y][z] == 1)
{
if (x != 2 * brushSize && splat[x + 1][y][z] == 1) {
growCheck++;
}
if (y != 2 * brushSize && splat[x][y + 1][z] == 1)
{
if (y != 2 * brushSize && splat[x][y + 1][z] == 1) {
growCheck++;
}
if (z != 2 * brushSize && splat[x][y][z + 1] == 1)
{
if (z != 2 * brushSize && splat[x][y][z + 1] == 1) {
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
tempSplat[x][y][z] = 1;
}
@ -211,10 +168,8 @@ public class BlobBrush extends PerformBrush
}
// integrate tempsplat back into splat at end of iteration
for (int x = brushSizeDoubled; x >= 0; x--)
{
for (int y = brushSizeDoubled; y >= 0; y--)
{
for (int x = brushSizeDoubled; x >= 0; x--) {
for (int y = brushSizeDoubled; y >= 0; y--) {
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);
// 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);
for (int y = brushSizeDoubled; y >= 0; y--)
{
for (int y = brushSizeDoubled; y >= 0; y--) {
final double ySquared = Math.pow(y - brushSize - 1, 2);
for (int z = brushSizeDoubled; z >= 0; z--)
{
if (splat[x][y][z] == 1 && xSquared + ySquared + Math.pow(z - brushSize - 1, 2) <= rSquared)
{
for (int z = brushSizeDoubled; z >= 0; z--) {
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));
}
}
@ -245,20 +196,17 @@ public class BlobBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.growBlob(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.digBlob(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
this.checkValidGrowPercent(null);
vm.brushName(this.getName());
@ -267,41 +215,31 @@ public class BlobBrush extends PerformBrush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
final String parameter = par[i];
if (parameter.equalsIgnoreCase("info"))
{
if (parameter.equalsIgnoreCase("info")) {
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);
return;
}
if (parameter.startsWith("g"))
{
if (parameter.startsWith("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 + "%");
this.growPercent = temp;
}
else
{
} else {
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.blob";
}
}

Datei anzeigen

@ -1,22 +1,19 @@
package com.thevoxelbox.voxelsniper.brush;
import java.util.ArrayList;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.Material;
import org.bukkit.block.Block;
import java.util.ArrayList;
/**
* @author MikeMatrix
*/
public class BlockResetBrush extends Brush
{
public class BlockResetBrush extends Brush {
private static final ArrayList<Material> DENIED_UPDATES = new ArrayList<>();
static
{
static {
BlockResetBrush.DENIED_UPDATES.add(Material.SIGN);
BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_SIGN_POST);
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");
}
@SuppressWarnings("deprecation")
private void applyBrush(final SnipeData v)
{
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++)
{
private void applyBrush(final SnipeData v) {
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++) {
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;
}
@ -65,26 +56,22 @@ public class BlockResetBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
applyBrush(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
applyBrush(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.blockreset";
}
}

Datei anzeigen

@ -1,17 +1,12 @@
package com.thevoxelbox.voxelsniper.brush;
import java.util.ArrayList;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.boydti.fawe.bukkit.wrapper.AsyncWorld;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
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
@ -28,90 +23,76 @@ import org.bukkit.block.Block;
*
* @author GavJenks
*/
public class BlockResetSurfaceBrush extends Brush
{
public class BlockResetSurfaceBrush extends Brush {
/**
*
*/
public BlockResetSurfaceBrush()
{
public BlockResetSurfaceBrush() {
this.setName("Block Reset Brush Surface Only");
}
@SuppressWarnings("deprecation")
private void applyBrush(final SnipeData v)
{
private void applyBrush(final SnipeData v) {
final AsyncWorld world = this.getWorld();
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 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++) {
AsyncBlock block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z);
Material type = block.getType();
BlockMaterial mat = BukkitAdapter.adapt(type).getMaterial();
if (!mat.isSolid() || !mat.isFullCube() || mat.hasContainer())
{
if (!mat.isSolid() || !mat.isFullCube() || mat.hasContainer()) {
continue;
}
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);
final int oldData = block.getPropertyId();
resetBlock(block, oldData);
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);
final int oldData = block.getPropertyId();
resetBlock(block, oldData);
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);
final int oldData = block.getPropertyId();
resetBlock(block, oldData);
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);
final int oldData = block.getPropertyId();
resetBlock(block, oldData);
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);
final int oldData = block.getPropertyId();
resetBlock(block, oldData);
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);
final int oldData = block.getPropertyId();
resetBlock(block, oldData);
airFound = true;
}
if (airFound)
{
if (airFound) {
block = world.getBlockAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + y, this.getTargetBlock().getZ() + z);
final int oldData = block.getPropertyId();
resetBlock(block, oldData);
@ -122,33 +103,28 @@ public class BlockResetSurfaceBrush extends Brush
}
@SuppressWarnings("deprecation")
private void resetBlock(AsyncBlock block, final int oldData)
{
block.setTypeIdAndPropertyId(block.getTypeId(), ((block.getPropertyId() + 1) & 0xf), true);
private void resetBlock(AsyncBlock block, final int oldData) {
block.setTypeIdAndPropertyId(block.getTypeId(), ((block.getPropertyId() + 1) & 0xf), true);
block.setTypeIdAndPropertyId(block.getTypeId(), oldData, true);
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
applyBrush(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
applyBrush(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.blockresetsurface";
}
}

Datei anzeigen

@ -11,15 +11,13 @@ import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import com.thevoxelbox.voxelsniper.util.BlockWrapper;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
/**
* 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;
/**
* Targeted Block.
@ -40,27 +38,20 @@ public abstract class Brush implements IBrush
* @param z
* @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;
if (clampedY < 0)
{
if (clampedY < 0) {
clampedY = 0;
}
else if (clampedY > this.getWorld().getMaxHeight())
{
} else if (clampedY > this.getWorld().getMaxHeight()) {
clampedY = this.getWorld().getMaxHeight();
}
return this.getWorld().getBlockAt(x, clampedY, z);
}
private boolean preparePerform(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace)
{
if (this.getTarget(v, clickedBlock, clickedFace))
{
if (this instanceof PerformBrush)
{
private boolean preparePerform(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace) {
if (this.getTarget(v, clickedBlock, clickedFace)) {
if (this instanceof PerformBrush) {
((PerformBrush) this).initP(v);
}
return true;
@ -70,12 +61,10 @@ public abstract class Brush implements IBrush
}
@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.setLastBlock(lastBlock);
switch (action)
{
switch (action) {
case ARROW:
this.arrow(data);
return true;
@ -92,8 +81,7 @@ public abstract class Brush implements IBrush
*
* @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
*/
protected void powder(final SnipeData v)
{
protected void powder(final SnipeData v) {
}
@Override
public abstract void info(Message vm);
@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.");
}
@ -122,52 +108,38 @@ public abstract class Brush implements IBrush
* @param clickedFace
* @return boolean
*/
protected final boolean getTarget(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace)
{
if (clickedBlock != null)
{
protected final boolean getTarget(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace) {
if (clickedBlock != null) {
this.setTargetBlock(clickedBlock);
this.setLastBlock(clickedBlock.getRelative(clickedFace));
if (this.getLastBlock() == null)
{
if (this.getLastBlock() == null) {
v.sendMessage(ChatColor.RED + "Snipe target block must be visible.");
return false;
}
if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isLightningEnabled())
{
if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isLightningEnabled()) {
this.getWorld().strikeLightning(this.getTargetBlock().getLocation());
}
return true;
}
else
{
} else {
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());
this.setTargetBlock(rangeBlockHelper.getRangeBlock());
}
else
{
} else {
rangeBlockHelper = new RangeBlockHelper(v.owner().getPlayer(), v.owner().getWorld());
this.setTargetBlock(rangeBlockHelper.getTargetBlock());
}
if (this.getTargetBlock() != null)
{
if (this.getTargetBlock() != null) {
this.setLastBlock(rangeBlockHelper.getLastBlock());
if (this.getLastBlock() == null)
{
if (this.getLastBlock() == null) {
v.sendMessage(ChatColor.RED + "Snipe target block must be visible.");
return false;
}
if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isLightningEnabled())
{
if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isLightningEnabled()) {
this.getWorld().strikeLightning(this.getTargetBlock().getLocation());
}
return true;
}
else
{
} else {
v.sendMessage(ChatColor.RED + "Snipe target block must be visible.");
return false;
}
@ -175,44 +147,38 @@ public abstract class Brush implements IBrush
}
@Override
public final String getName()
{
public final String getName() {
return this.name;
}
@Override
public final void setName(final String name)
{
public final void setName(final String name) {
this.name = name;
}
@Override
public String getBrushCategory()
{
public String getBrushCategory() {
return "General";
}
/**
* @return the targetBlock
*/
protected final AsyncBlock getTargetBlock()
{
protected final AsyncBlock getTargetBlock() {
return this.targetBlock;
}
/**
* @param targetBlock the targetBlock to set
*/
protected final void setTargetBlock(final AsyncBlock targetBlock)
{
protected final void setTargetBlock(final AsyncBlock targetBlock) {
this.targetBlock = targetBlock;
}
/**
* @return the world
*/
protected final AsyncWorld getWorld()
{
protected final AsyncWorld 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.
*/
@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();
}
protected Block getBlockAt(int x, int y, int z)
{
protected Block getBlockAt(int x, int y, int 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();
}
@ -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.
*/
@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 Block before target Block.
*/
protected final AsyncBlock getLastBlock()
{
protected final AsyncBlock getLastBlock() {
return this.lastBlock;
}
/**
* @param lastBlock Last Block before target Block.
*/
protected final void setLastBlock(AsyncBlock lastBlock)
{
protected final void setLastBlock(AsyncBlock lastBlock) {
this.lastBlock = lastBlock;
}
@ -276,8 +236,7 @@ public abstract class Brush implements IBrush
* @param blockWrapper Block data wrapper
*/
@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());
}
@ -290,8 +249,7 @@ public abstract class Brush implements IBrush
* @param id The id the block will be set to
*/
@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);
}
@ -305,8 +263,7 @@ public abstract class Brush implements IBrush
* @param data The data value the block will be set to
*/
@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);
}
@ -320,8 +277,7 @@ public abstract class Brush implements IBrush
* @param data The data value the block will be set to
*/
@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());
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -3,22 +3,19 @@ package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
/**
* @author MikeMatrix
*/
public class CheckerVoxelDiscBrush extends PerformBrush
{
public class CheckerVoxelDiscBrush extends PerformBrush {
private boolean useWorldCoordinates = true;
/**
* Default constructor.
*/
public CheckerVoxelDiscBrush()
{
public CheckerVoxelDiscBrush() {
this.setName("Checker Voxel Disc");
}
@ -26,15 +23,11 @@ public class CheckerVoxelDiscBrush extends PerformBrush
* @param v
* @param target
*/
private void applyBrush(final SnipeData v, final Block target)
{
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--)
{
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--)
{
private void applyBrush(final SnipeData v, final Block target) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); 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));
}
}
@ -43,50 +36,39 @@ public class CheckerVoxelDiscBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.applyBrush(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.applyBrush(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int x = 1; x < par.length; x++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int x = 1; x < par.length; x++) {
final String parameter = par[x].toLowerCase();
if (parameter.equals("info"))
{
if (parameter.equals("info")) {
v.sendMessage(ChatColor.GOLD + this.getName() + " Parameters:");
v.sendMessage(ChatColor.AQUA + "true -- Enables using World Coordinates.");
v.sendMessage(ChatColor.AQUA + "false -- Disables using World Coordinates.");
return;
}
if (parameter.startsWith("true"))
{
if (parameter.startsWith("true")) {
this.useWorldCoordinates = true;
v.sendMessage(ChatColor.AQUA + "Enabled using World Coordinates.");
}
else if (parameter.startsWith("false"))
{
} else if (parameter.startsWith("false")) {
this.useWorldCoordinates = false;
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.");
break;
}
@ -94,8 +76,7 @@ public class CheckerVoxelDiscBrush extends PerformBrush
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -13,38 +12,30 @@ import org.bukkit.Material;
*
* @author psanker
*/
public class CleanSnowBrush extends Brush
{
public class CleanSnowBrush extends Brush {
private double trueCircle = 0;
/**
*
*/
public CleanSnowBrush()
{
public CleanSnowBrush() {
this.setName("Clean Snow");
}
private void cleanSnow(final SnipeData v)
{
private void cleanSnow(final SnipeData v) {
final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
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);
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);
for (int z = (brushSize + 1) * 2; z >= 0; z--)
{
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())))
{
for (int z = (brushSize + 1) * 2; z >= 0; z--) {
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()))) {
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());
}
@ -58,57 +49,44 @@ public class CleanSnowBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.cleanSnow(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.cleanSnow(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; 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.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;
}
else if (parameter.startsWith("true"))
{
} else if (parameter.startsWith("true")) {
this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
}
else if (parameter.startsWith("false"))
{
} else if (parameter.startsWith("false")) {
this.trueCircle = 0;
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.cleansnow";
}
}

Datei anzeigen

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

Datei anzeigen

@ -1,79 +1,62 @@
package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.LargeFireball;
import org.bukkit.entity.SmallFireball;
import org.bukkit.util.Vector;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
/**
* @author Gavjenks Heavily revamped from ruler brush blockPositionY
* @author Giltwist
* @author Monofraps (Merged Meteor brush)
*/
public class CometBrush extends Brush
{
public class CometBrush extends Brush {
private boolean useBigBalls = false;
/**
*
*/
public CometBrush()
{
public CometBrush() {
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 Location playerLocation = v.owner().getPlayer().getEyeLocation();
final Vector slope = targetCoords.subtract(playerLocation.toVector());
if (useBigBalls)
{
if (useBigBalls) {
v.owner().getPlayer().launchProjectile(LargeFireball.class).setVelocity(slope.normalize());
}
else
{
} else {
v.owner().getPlayer().launchProjectile(SmallFireball.class).setVelocity(slope.normalize());
}
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 0; i < par.length; ++i)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 0; i < par.length; ++i) {
String parameter = par[i];
if (parameter.equalsIgnoreCase("info"))
{
if (parameter.equalsIgnoreCase("info")) {
v.sendMessage("Parameters:");
v.sendMessage("balls [big|small] -- Sets your ball size.");
}
if (parameter.equalsIgnoreCase("balls"))
{
if (i + 1 >= par.length)
{
if (parameter.equalsIgnoreCase("balls")) {
if (i + 1 >= par.length) {
v.sendMessage("The balls parameter expects a ball size after it.");
}
String newBallSize = par[++i];
if (newBallSize.equalsIgnoreCase("big"))
{
if (newBallSize.equalsIgnoreCase("big")) {
useBigBalls = true;
v.sendMessage("Your balls are " + ChatColor.DARK_RED + ("BIG"));
}
else if (newBallSize.equalsIgnoreCase("small"))
{
} else if (newBallSize.equalsIgnoreCase("small")) {
useBigBalls = false;
v.sendMessage("Your balls are " + ChatColor.DARK_RED + ("small"));
}
else
{
} else {
v.sendMessage("Unknown ball size.");
}
}
@ -81,28 +64,24 @@ public class CometBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.doFireball(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.doFireball(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.voxel();
vm.custom("Your balls are " + ChatColor.DARK_RED + (useBigBalls ? "BIG" : "small"));
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
/**
* http://www.voxelwiki.com/minecraft/Voxelsniper#CopyPasta_Brush
*
* @author giltwist
*/
public class CopyPastaBrush extends Brush
{
public class CopyPastaBrush extends Brush {
private static final int BLOCK_LIMIT = 10000;
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");
}
@SuppressWarnings("deprecation")
private void doCopy(final SnipeData v)
{
for (int i = 0; i < 3; i++)
{
private void doCopy(final SnipeData v) {
for (int i = 0; i < 3; i++) {
this.arraySize[i] = Math.abs(this.firstPoint[i] - this.secondPoint[i]) + 1;
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
@ -50,16 +44,12 @@ public class CopyPastaBrush extends Brush
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];
for (int i = 0; i < this.arraySize[0]; i++)
{
for (int j = 0; j < this.arraySize[1]; j++)
{
for (int k = 0; k < this.arraySize[2]; k++)
{
for (int i = 0; i < this.arraySize[0]; i++) {
for (int j = 0; j < this.arraySize[1]; j++) {
for (int k = 0; k < this.arraySize[2]; 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();
}
@ -67,29 +57,22 @@ public class CopyPastaBrush extends Brush
}
v.sendMessage(ChatColor.AQUA + "" + this.numBlocks + " blocks copied.");
}
else
{
} else {
v.sendMessage(ChatColor.RED + "Copy area too big: " + this.numBlocks + "(Limit: " + CopyPastaBrush.BLOCK_LIMIT + ")");
}
}
@SuppressWarnings("deprecation")
private void doPasta(final SnipeData v)
{
private void doPasta(final SnipeData v) {
final Undo undo = new Undo();
for (int i = 0; i < this.arraySize[0]; i++)
{
for (int j = 0; j < this.arraySize[1]; j++)
{
for (int k = 0; k < this.arraySize[2]; k++)
{
for (int i = 0; i < this.arraySize[0]; i++) {
for (int j = 0; j < this.arraySize[1]; j++) {
for (int k = 0; k < this.arraySize[2]; k++) {
final int currentPosition = i + this.arraySize[0] * j + this.arraySize[0] * this.arraySize[1] * k;
AsyncBlock block;
switch (this.pivot)
{
switch (this.pivot) {
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);
break;
@ -104,11 +87,9 @@ public class CopyPastaBrush extends Brush
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);
}
block.setCombinedId(this.blockArray[currentPosition]);
@ -122,10 +103,8 @@ public class CopyPastaBrush extends Brush
}
@Override
protected final void arrow(final com.thevoxelbox.voxelsniper.SnipeData v)
{
switch (this.points)
{
protected final void arrow(final com.thevoxelbox.voxelsniper.SnipeData v) {
switch (this.points) {
case 0:
this.firstPoint[0] = this.getTargetBlock().getX();
this.firstPoint[1] = this.getTargetBlock().getY();
@ -152,71 +131,56 @@ public class CopyPastaBrush extends Brush
}
@Override
protected final void powder(final com.thevoxelbox.voxelsniper.SnipeData v)
{
if (this.points == 2)
{
if (this.numBlocks == 0)
{
protected final void powder(final com.thevoxelbox.voxelsniper.SnipeData v) {
if (this.points == 2) {
if (this.numBlocks == 0) {
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[1] = this.getTargetBlock().getY();
this.pastePoint[2] = this.getTargetBlock().getZ();
this.doPasta(v);
}
else
{
} else {
v.sendMessage(ChatColor.RED + "Error");
}
}
else
{
} else {
v.sendMessage(ChatColor.RED + "You must select exactly two points.");
}
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.custom(ChatColor.GOLD + "Paste air: " + this.pasteAir);
vm.custom(ChatColor.GOLD + "Pivot angle: " + this.pivot);
}
@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];
if (parameter.equalsIgnoreCase("info"))
{
if (parameter.equalsIgnoreCase("info")) {
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 0|90|180|270 -- toggle rotation (0 default)");
return;
}
if (parameter.equalsIgnoreCase("air"))
{
if (parameter.equalsIgnoreCase("air")) {
this.pasteAir = !this.pasteAir;
v.sendMessage(ChatColor.GOLD + "Paste air: " + this.pasteAir);
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);
v.sendMessage(ChatColor.GOLD + "Pivot angle: " + this.pivot);
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.copypasta";
}
}

Datei anzeigen

@ -9,61 +9,47 @@ import org.bukkit.block.Block;
/**
* @author Kavutop
*/
public class CylinderBrush extends PerformBrush
{
public class CylinderBrush extends PerformBrush {
private double trueCircle = 0;
/**
*
*/
public CylinderBrush()
{
public CylinderBrush() {
this.setName("Cylinder");
}
private void cylinder(final SnipeData v, Block targetBlock)
{
private void cylinder(final SnipeData v, Block targetBlock) {
final int brushSize = v.getBrushSize();
int yStartingPoint = targetBlock.getY() + v.getcCen();
int yEndPoint = targetBlock.getY() + v.getVoxelHeight() + v.getcCen();
if (yEndPoint < yStartingPoint)
{
if (yEndPoint < yStartingPoint) {
yEndPoint = yStartingPoint;
}
if (yStartingPoint < 0)
{
if (yStartingPoint < 0) {
yStartingPoint = 0;
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;
v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world start position.");
}
if (yEndPoint < 0)
{
if (yEndPoint < 0) {
yEndPoint = 0;
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;
v.sendMessage(ChatColor.DARK_PURPLE + "Warning: off-world end position.");
}
final double bSquared = Math.pow(brushSize + this.trueCircle, 2);
for (int y = yEndPoint; y >= yStartingPoint; y--)
{
for (int x = brushSize; x >= 0; x--)
{
for (int y = yEndPoint; y >= yStartingPoint; y--) {
for (int x = brushSize; x >= 0; x--) {
final double xSquared = Math.pow(x, 2);
for (int z = brushSize; z >= 0; z--)
{
if ((xSquared + Math.pow(z, 2)) <= bSquared)
{
for (int z = brushSize; z >= 0; z--) {
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));
@ -76,20 +62,17 @@ public class CylinderBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.cylinder(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.cylinder(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
vm.height();
@ -97,50 +80,37 @@ public class CylinderBrush extends PerformBrush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
final String parameter = par[i];
if (parameter.equalsIgnoreCase("info"))
{
if (parameter.equalsIgnoreCase("info")) {
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.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.");
return;
}
if (parameter.startsWith("true"))
{
if (parameter.startsWith("true")) {
this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
}
else if (parameter.startsWith("false"))
{
} else if (parameter.startsWith("false")) {
this.trueCircle = 0;
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.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.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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.cylinder";
}
}

Datei anzeigen

@ -3,7 +3,6 @@ package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
@ -13,15 +12,13 @@ import org.bukkit.util.Vector;
*
* @author Voxel
*/
public class DiscBrush extends PerformBrush
{
public class DiscBrush extends PerformBrush {
private double trueCircle = 0;
/**
* Default Constructor.
*/
public DiscBrush()
{
public DiscBrush() {
this.setName("Disc");
}
@ -30,20 +27,16 @@ public class DiscBrush extends PerformBrush
*
* @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 Vector centerPoint = targetBlock.getLocation().toVector();
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);
for (int z = -v.getBrushSize(); z <= v.getBrushSize(); z++)
{
for (int z = -v.getBrushSize(); z <= v.getBrushSize(); 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()));
}
}
@ -52,57 +45,44 @@ public class DiscBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.disc(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.disc(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
final String parameter = par[i].toLowerCase();
if (parameter.equalsIgnoreCase("info"))
{
if (parameter.equalsIgnoreCase("info")) {
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)");
return;
}
else if (parameter.startsWith("true"))
{
} else if (parameter.startsWith("true")) {
this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
}
else if (parameter.startsWith("false"))
{
} else if (parameter.startsWith("false")) {
this.trueCircle = 0;
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.disc";
}
}

Datei anzeigen

@ -5,7 +5,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
/**
@ -13,31 +12,25 @@ import org.bukkit.block.BlockFace;
*
* @author Voxel
*/
public class DiscFaceBrush extends PerformBrush
{
public class DiscFaceBrush extends PerformBrush {
private double trueCircle = 0;
/**
*
*/
public DiscFaceBrush()
{
public DiscFaceBrush() {
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 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);
for (int z = brushSize; z >= 0; z--)
{
if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared)
{
for (int z = brushSize; z >= 0; z--) {
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));
@ -49,18 +42,14 @@ public class DiscFaceBrush extends PerformBrush
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 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);
for (int y = brushSize; y >= 0; y--)
{
if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared)
{
for (int y = brushSize; y >= 0; y--) {
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));
@ -72,18 +61,14 @@ public class DiscFaceBrush extends PerformBrush
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 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);
for (int y = brushSize; y >= 0; y--)
{
if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared)
{
for (int y = brushSize; y >= 0; y--) {
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));
@ -95,15 +80,12 @@ public class DiscFaceBrush extends PerformBrush
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());
if (blockFace == null)
{
if (blockFace == null) {
return;
}
switch (blockFace)
{
switch (blockFace) {
case NORTH:
case SOUTH:
this.discNS(v, targetBlock);
@ -125,57 +107,45 @@ public class DiscFaceBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.pre(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.pre(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; 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.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;
}
if (parameter.startsWith("true"))
{
if (parameter.startsWith("true")) {
this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
}
else if (parameter.startsWith("false"))
{
} else if (parameter.startsWith("false")) {
this.trueCircle = 0;
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.discface";
}
}

Datei anzeigen

@ -1,36 +1,32 @@
package com.thevoxelbox.voxelsniper.brush;
import java.util.HashSet;
import java.util.Set;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.block.Block;
import org.bukkit.util.NumberConversions;
import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.Set;
/**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Dome_Brush
*
* @author Gavjenks
* @author MikeMatrix
*/
public class DomeBrush extends Brush
{
public class DomeBrush extends Brush {
/**
*
*/
public DomeBrush()
{
public DomeBrush() {
this.setName("Dome");
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
vm.voxel();
@ -42,11 +38,9 @@ public class DomeBrush extends Brush
* @param targetBlock
*/
@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.");
return;
}
@ -63,11 +57,9 @@ public class DomeBrush extends Brush
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);
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 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();
if (currentTargetBlock.getTypeId() != v.getVoxelId() || currentTargetBlock.getPropertyId() != v.getPropertyId())
{
if (currentTargetBlock.getTypeId() != v.getVoxelId() || currentTargetBlock.getPropertyId() != v.getPropertyId()) {
undo.put(currentTargetBlock);
currentTargetBlock.setTypeIdAndPropertyId(v.getVoxelId(), v.getPropertyId(), true);
}
@ -100,20 +90,17 @@ public class DomeBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.generateDome(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.generateDome(v, this.getLastBlock());
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.Material;
/**
* http://www.voxelwiki.com/minecraft/Voxelsniper#The_Drain_Brush
@ -14,79 +12,61 @@ import org.bukkit.Material;
* @author Gavjenks
* @author psanker
*/
public class DrainBrush extends Brush
{
public class DrainBrush extends Brush {
private double trueCircle = 0;
private boolean disc = false;
/**
*
*/
public DrainBrush()
{
public DrainBrush() {
this.setName("Drain");
}
@SuppressWarnings("deprecation")
private void drain(final SnipeData v)
{
private void drain(final SnipeData v) {
final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
final Undo undo = new Undo();
if (this.disc)
{
for (int x = brushSize; x >= 0; x--)
{
if (this.disc) {
for (int x = brushSize; x >= 0; x--) {
final double xSquared = Math.pow(x, 2);
for (int y = brushSize; y >= 0; y--)
{
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())
{
for (int y = brushSize; y >= 0; y--) {
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()) {
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());
}
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));
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));
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));
this.setBlockIdAt(this.getTargetBlock().getZ() - y, this.getTargetBlock().getX() - x, this.getTargetBlock().getY(), BlockTypes.AIR.getInternalId());
}
}
}
}
}
else
{
for (int y = (brushSize + 1) * 2; y >= 0; y--)
{
} else {
for (int y = (brushSize + 1) * 2; y >= 0; y--) {
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);
for (int z = (brushSize + 1) * 2; z >= 0; z--)
{
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())
{
for (int z = (brushSize + 1) * 2; z >= 0; z--) {
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()) {
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());
}
@ -100,20 +80,17 @@ public class DrainBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.drain(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.drain(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
@ -122,52 +99,37 @@ public class DrainBrush extends Brush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
final String parameter = par[i];
if (parameter.equalsIgnoreCase("info"))
{
if (parameter.equalsIgnoreCase("info")) {
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 d -- toggles disc drain mode, as opposed to a ball drain mode");
return;
}
else if (parameter.startsWith("true"))
{
} else if (parameter.startsWith("true")) {
this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
}
else if (parameter.startsWith("false"))
{
} else if (parameter.startsWith("false")) {
this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
}
else if (parameter.equalsIgnoreCase("d"))
{
if (this.disc)
{
} else if (parameter.equalsIgnoreCase("d")) {
if (this.disc) {
this.disc = false;
v.sendMessage(ChatColor.AQUA + "Disc drain mode OFF");
}
else
{
} else {
this.disc = true;
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.drain";
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -2,7 +2,6 @@ package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor;
import org.bukkit.entity.EntityType;
@ -11,88 +10,69 @@ import org.bukkit.entity.EntityType;
*
* @author Piotr
*/
public class EntityBrush extends Brush
{
public class EntityBrush extends Brush {
private EntityType entityType = EntityType.ZOMBIE;
/**
*
*/
public EntityBrush()
{
public EntityBrush() {
this.setName("Entity");
}
private void spawn(final SnipeData v)
{
for (int x = 0; x < v.getBrushSize(); x++)
{
try
{
private void spawn(final SnipeData v) {
for (int x = 0; x < v.getBrushSize(); x++) {
try {
this.getWorld().spawn(this.getLastBlock().getLocation(), this.entityType.getEntityClass());
}
catch (final IllegalArgumentException exception)
{
} catch (final IllegalArgumentException exception) {
v.sendMessage(ChatColor.RED + "Cannot spawn entity!");
}
}
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.spawn(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.spawn(v);
}
@SuppressWarnings("deprecation")
@Override
public final void info(final Message vm)
{
@Override
public final void info(final Message vm) {
vm.brushMessage(ChatColor.LIGHT_PURPLE + "Entity brush" + " (" + this.entityType.getName() + ")");
vm.size();
}
@SuppressWarnings("deprecation")
@Override
public final void parameters(final String[] par, final SnipeData v)
{
if (par[1].equalsIgnoreCase("info"))
{
@Override
public final void parameters(final String[] par, final SnipeData v) {
if (par[1].equalsIgnoreCase("info")) {
String names = "";
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 + " |";
v.sendMessage(names);
}
else
{
} else {
final EntityType currentEntity = EntityType.fromName(par[1]);
if (currentEntity != null)
{
if (currentEntity != null) {
this.entityType = currentEntity;
v.sendMessage(ChatColor.GREEN + "Entity type set to " + this.entityType.getName());
}
else
{
} else {
v.sendMessage(ChatColor.RED + "This is not a valid entity!");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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);
/**
*
*/
public EntityRemovalBrush()
{
public EntityRemovalBrush() {
this.setName("Entity Removal");
exemptions.add("org.bukkit.entity.Player");
@ -30,30 +28,24 @@ public class EntityRemovalBrush extends Brush
exemptions.add("org.bukkit.entity.NPC");
}
private void radialRemoval(SnipeData v)
{
private void radialRemoval(SnipeData v) {
final Chunk targetChunk = getTargetBlock().getChunk();
int entityCount = 0;
int chunkCount = 0;
try
{
try {
entityCount += removeEntities(targetChunk);
int radius = Math.round(v.getBrushSize() / 16);
for (int x = targetChunk.getX() - radius; x <= targetChunk.getX() + radius; x++)
{
for (int z = targetChunk.getZ() - radius; z <= targetChunk.getZ() + radius; z++)
{
for (int x = targetChunk.getX() - radius; x <= targetChunk.getX() + radius; x++) {
for (int z = targetChunk.getZ() - radius; z <= targetChunk.getZ() + radius; z++) {
entityCount += removeEntities(getWorld().getChunkAt(x, z));
chunkCount++;
}
}
}
catch (final PatternSyntaxException pse)
{
} catch (final PatternSyntaxException pse) {
pse.printStackTrace();
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()));
@ -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."));
}
private int removeEntities(Chunk chunk) throws PatternSyntaxException
{
private int removeEntities(Chunk chunk) throws PatternSyntaxException {
int entityCount = 0;
for (Entity entity : chunk.getEntities())
{
if (isClassInExemptionList(entity.getClass()))
{
for (Entity entity : chunk.getEntities()) {
if (isClassInExemptionList(entity.getClass())) {
continue;
}
@ -79,30 +68,24 @@ public class EntityRemovalBrush extends Brush
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
final List<String> entityClassHierarchy = new ArrayList<>();
Class<?> currentClass = entityClass;
while (currentClass != null && !currentClass.equals(Object.class))
{
while (currentClass != null && !currentClass.equals(Object.class)) {
entityClassHierarchy.add(currentClass.getCanonicalName());
for (final Class<?> intrf : currentClass.getInterfaces())
{
for (final Class<?> intrf : currentClass.getInterfaces()) {
entityClassHierarchy.add(intrf.getCanonicalName());
}
currentClass = currentClass.getSuperclass();
}
for (final String exemptionPattern : exemptions)
{
for (final String typeName : entityClassHierarchy)
{
if (typeName.matches(exemptionPattern))
{
for (final String exemptionPattern : exemptions) {
for (final String typeName : entityClassHierarchy) {
if (typeName.matches(exemptionPattern)) {
return true;
}
@ -113,28 +96,23 @@ public class EntityRemovalBrush extends Brush
}
@Override
protected void arrow(SnipeData v)
{
protected void arrow(SnipeData v) {
this.radialRemoval(v);
}
@Override
protected void powder(SnipeData v)
{
protected void powder(SnipeData v) {
this.radialRemoval(v);
}
@Override
public void info(Message vm)
{
public void info(Message vm) {
vm.brushName(getName());
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());
if (it.hasNext())
{
if (it.hasNext()) {
exemptionsList.append(", ");
}
}
@ -144,12 +122,9 @@ public class EntityRemovalBrush extends Brush
}
@Override
public void parameters(final String[] par, final SnipeData v)
{
for (final String currentParam : par)
{
if (currentParam.startsWith("+") || currentParam.startsWith("-"))
{
public void parameters(final String[] par, final SnipeData v) {
for (final String currentParam : par) {
if (currentParam.startsWith("+") || currentParam.startsWith("-")) {
final boolean isAddOperation = currentParam.startsWith("+");
// +#/-# will suppress auto-prefixing
@ -157,22 +132,17 @@ public class EntityRemovalBrush extends Brush
currentParam.substring(2) :
(currentParam.contains(".") ? currentParam.substring(1) : ".*." + currentParam.substring(1));
if (isAddOperation)
{
if (isAddOperation) {
exemptions.add(exemptionPattern);
v.sendMessage(String.format("Added %s to entity exemptions list.", exemptionPattern));
}
else
{
} else {
exemptions.remove(exemptionPattern);
v.sendMessage(String.format("Removed %s from entity exemptions list.", exemptionPattern));
}
}
if (currentParam.equalsIgnoreCase("list-exemptions") || currentParam.equalsIgnoreCase("lex"))
{
for (final String exemption : exemptions)
{
if (currentParam.equalsIgnoreCase("list-exemptions") || currentParam.equalsIgnoreCase("lex")) {
for (final String exemption : exemptions) {
v.sendMessage(ChatColor.LIGHT_PURPLE + exemption);
}
}
@ -180,8 +150,7 @@ public class EntityRemovalBrush extends Brush
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.entityremoval";
}
}

Datei anzeigen

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

Datei anzeigen

@ -20,11 +20,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.ChatPaginator;
import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* http://www.voxelwiki.com/minecraft/VoxelSniper#The_Erosion_Brush
@ -32,8 +28,7 @@ import java.util.Map;
* @author Piotr
* @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 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);
@ -41,20 +36,16 @@ public class ErodeBrush extends Brush
/**
*
*/
public ErodeBrush()
{
public ErodeBrush() {
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 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("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."));
}
catch (JSAPException ignored)
{
} catch (JSAPException ignored) {
}
}
@ -64,13 +55,10 @@ public class ErodeBrush extends Brush
* @param helpJSAP
* @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);
if (!output.isEmpty())
{
for (final String string : output)
{
if (!output.isEmpty()) {
for (final String string : output) {
player.sendMessage(string);
}
return true;
@ -79,32 +67,27 @@ public class ErodeBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.erosion(v, this.currentPreset);
}
@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 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);
}
for (int i = 0; i < erosionPreset.getFillRecursion(); ++i)
{
for (int i = 0; i < erosionPreset.getFillRecursion(); ++i) {
fillIteration(v, erosionPreset, blockChangeTracker, targetBlockVector);
}
final Undo undo = new Undo();
for (final BlockWrapper blockWrapper : blockChangeTracker.getAll())
{
for (final BlockWrapper blockWrapper : blockChangeTracker.getAll()) {
undo.put(blockWrapper.getBlock());
blockWrapper.getBlock().setTypeIdAndPropertyId(BukkitAdapter.adapt(blockWrapper.getMaterial()).getInternalId(), blockWrapper.getPropertyId(), true);
}
@ -112,22 +95,16 @@ public class ErodeBrush extends Brush
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();
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 y = this.getTargetBlock().getY() - v.getBrushSize(); y <= this.getTargetBlock().getY() + v.getBrushSize(); ++y)
{
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 y = this.getTargetBlock().getY() - v.getBrushSize(); y <= this.getTargetBlock().getY() + v.getBrushSize(); ++y) {
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);
if (!(currentBlock.isEmpty() || currentBlock.isLiquid()))
{
if (!(currentBlock.isEmpty() || currentBlock.isLiquid())) {
continue;
}
@ -135,41 +112,33 @@ public class ErodeBrush extends Brush
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 BlockWrapper relativeBlock = blockChangeTracker.get(relativePosition, currentIteration);
if (!(relativeBlock.isEmpty() || relativeBlock.isLiquid()))
{
if (!(relativeBlock.isEmpty() || relativeBlock.isLiquid())) {
count++;
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);
}
else
{
} else {
blockCount.put(typeBlock, 1);
}
}
}
BlockWrapper currentMaterial = new BlockWrapper(null, Material.AIR, 0);
BlockWrapper currentMaterial = new BlockWrapper(null, Material.AIR, 0);
int amount = 0;
for (final BlockWrapper wrapper : blockCount.keySet())
{
for (final BlockWrapper wrapper : blockCount.keySet()) {
final Integer currentCount = blockCount.get(wrapper);
if (amount <= currentCount)
{
if (amount <= currentCount) {
currentMaterial = wrapper;
amount = currentCount;
}
}
if (count >= erosionPreset.getFillFaces())
{
if (count >= erosionPreset.getFillFaces()) {
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();
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 y = this.getTargetBlock().getY() - v.getBrushSize(); y <= this.getTargetBlock().getY() + v.getBrushSize(); ++y)
{
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 y = this.getTargetBlock().getY() - v.getBrushSize(); y <= this.getTargetBlock().getY() + v.getBrushSize(); ++y) {
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);
if (currentBlock.isEmpty() || currentBlock.isLiquid())
{
if (currentBlock.isEmpty() || currentBlock.isLiquid()) {
continue;
}
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 BlockWrapper relativeBlock = blockChangeTracker.get(relativePosition, currentIteration);
if (relativeBlock.isEmpty() || relativeBlock.isLiquid())
{
if (relativeBlock.isEmpty() || relativeBlock.isLiquid()) {
count++;
}
}
if (count >= erosionPreset.getErosionFaces())
{
blockChangeTracker.put(currentPosition, new BlockWrapper(currentBlock.getBlock(), Material.AIR, 0), currentIteration);
if (count >= erosionPreset.getErosionFaces()) {
blockChangeTracker.put(currentPosition, new BlockWrapper(currentBlock.getBlock(), Material.AIR, 0), currentIteration);
}
}
}
@ -220,14 +180,12 @@ public class ErodeBrush extends Brush
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.erosion(v, this.currentPreset.getInverted());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
vm.custom(ChatColor.AQUA + "Erosion minimum exposed faces set to " + this.currentPreset.getErosionFaces());
@ -237,25 +195,19 @@ public class ErodeBrush extends Brush
}
@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));
if (sendHelpOrErrorMessageToPlayer(result, v.owner().getPlayer(), this.parser))
{
if (sendHelpOrErrorMessageToPlayer(result, v.owner().getPlayer(), this.parser)) {
return;
}
if (result.getString("preset") != null)
{
try
{
if (result.getString("preset") != null) {
try {
this.currentPreset = Preset.valueOf(result.getString("preset").toUpperCase()).getPreset();
v.getVoxelMessage().brushMessage("Brush preset set to " + result.getString("preset"));
return;
}
catch (final IllegalArgumentException exception)
{
} catch (final IllegalArgumentException exception) {
v.getVoxelMessage().brushMessage("No such preset.");
return;
}
@ -263,57 +215,51 @@ public class ErodeBrush extends Brush
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());
}
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());
}
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"));
}
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());
}
if (!currentPreset.equals(currentPresetBackup))
{
if (currentPreset.getErosionFaces() != currentPresetBackup.getErosionFaces())
{
if (!currentPreset.equals(currentPresetBackup)) {
if (currentPreset.getErosionFaces() != currentPresetBackup.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());
}
if (currentPreset.getErosionRecursion() != currentPresetBackup.getErosionRecursion())
{
if (currentPreset.getErosionRecursion() != currentPresetBackup.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());
}
}
}
@Override
public String getPermissionNode() {
return "voxelsniper.brush.erode";
}
/**
* @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));
private ErosionPreset preset;
Preset(final ErosionPreset preset)
{
Preset(final ErosionPreset preset) {
this.preset = preset;
}
@ -323,19 +269,14 @@ public class ErodeBrush extends Brush
* @param seperator Seperator for delimiting entries.
* @return
*/
public static String getValuesString(String seperator)
{
public static String getValuesString(String seperator) {
String valuesString = "";
boolean delimiterHelper = true;
for (final Preset preset : Preset.values())
{
if (delimiterHelper)
{
for (final Preset preset : Preset.values()) {
if (delimiterHelper) {
delimiterHelper = false;
}
else
{
} else {
valuesString += seperator;
}
valuesString += preset.name();
@ -343,8 +284,7 @@ public class ErodeBrush extends Brush
return valuesString;
}
public ErosionPreset getPreset()
{
public ErosionPreset getPreset() {
return this.preset;
}
@ -354,28 +294,23 @@ public class ErodeBrush extends Brush
/**
* @author MikeMatrix
*/
private static final class BlockChangeTracker
{
private static final class BlockChangeTracker {
private final Map<Integer, Map<Vector, BlockWrapper>> blockChanges;
private final Map<Vector, BlockWrapper> flatChanges;
private final AsyncWorld world;
private int nextIterationId = 0;
public BlockChangeTracker(final AsyncWorld world)
{
public BlockChangeTracker(final AsyncWorld world) {
this.blockChanges = new HashMap<>();
this.flatChanges = new HashMap<>();
this.world = world;
}
public BlockWrapper get(final Vector position, final int iteration)
{
public BlockWrapper get(final Vector position, final int iteration) {
BlockWrapper changedBlock = null;
for (int i = iteration - 1; i >= 0; --i)
{
if (this.blockChanges.containsKey(i) && this.blockChanges.get(i).containsKey(position))
{
for (int i = iteration - 1; i >= 0; --i) {
if (this.blockChanges.containsKey(i) && this.blockChanges.get(i).containsKey(position)) {
changedBlock = this.blockChanges.get(i).get(position);
return changedBlock;
}
@ -386,20 +321,16 @@ public class ErodeBrush extends Brush
return changedBlock;
}
public Collection<BlockWrapper> getAll()
{
public Collection<BlockWrapper> getAll() {
return this.flatChanges.values();
}
public int nextIteration()
{
public int nextIteration() {
return this.nextIterationId++;
}
public void put(final Vector position, final BlockWrapper changedBlock, final int iteration)
{
if (!this.blockChanges.containsKey(iteration))
{
public void put(final Vector position, final BlockWrapper changedBlock, final int iteration) {
if (!this.blockChanges.containsKey(iteration)) {
this.blockChanges.put(iteration, new HashMap<>());
}
@ -411,23 +342,20 @@ public class ErodeBrush extends Brush
/**
* @author MikeMatrix
*/
private static final class BlockWrapper
{
private static final class BlockWrapper {
private final AsyncBlock block;
private final Material material;
private final int data;
@SuppressWarnings("deprecation")
public BlockWrapper(final AsyncBlock block)
{
public BlockWrapper(final AsyncBlock block) {
this.block = block;
this.data = block.getPropertyId();
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.material = material;
this.data = data;
@ -436,32 +364,28 @@ public class ErodeBrush extends Brush
/**
* @return the block
*/
public AsyncBlock getBlock()
{
public AsyncBlock getBlock() {
return this.block;
}
/**
* @return the data
*/
public int getPropertyId()
{
public int getPropertyId() {
return this.data;
}
/**
* @return the material
*/
public Material getMaterial()
{
public Material getMaterial() {
return this.material;
}
/**
* @return if the block is Empty.
*/
public boolean isEmpty()
{
public boolean isEmpty() {
switch (material) {
case AIR:
case CAVE_AIR:
@ -475,10 +399,8 @@ public class ErodeBrush extends Brush
/**
* @return if the block is a Liquid.
*/
public boolean isLiquid()
{
switch (this.material)
{
public boolean isLiquid() {
switch (this.material) {
case WATER:
case LAVA:
return true;
@ -492,15 +414,13 @@ public class ErodeBrush extends Brush
/**
* @author MikeMatrix
*/
private static final class ErosionPreset
{
private static final class ErosionPreset {
private final int erosionFaces;
private final int erosionRecursion;
private final int fillFaces;
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.erosionRecursion = erosionRecursion;
this.fillFaces = fillFaces;
@ -508,16 +428,13 @@ public class ErodeBrush extends Brush
}
@Override
public int hashCode()
{
public int hashCode() {
return Objects.hashCode(erosionFaces, erosionRecursion, fillFaces, fillRecursion);
}
@Override
public boolean equals(final Object obj)
{
if (obj instanceof ErosionPreset)
{
public boolean equals(final Object obj) {
if (obj instanceof ErosionPreset) {
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);
}
@ -527,44 +444,33 @@ public class ErodeBrush extends Brush
/**
* @return the erosionFaces
*/
public int getErosionFaces()
{
public int getErosionFaces() {
return this.erosionFaces;
}
/**
* @return the erosionRecursion
*/
public int getErosionRecursion()
{
public int getErosionRecursion() {
return this.erosionRecursion;
}
/**
* @return the fillFaces
*/
public int getFillFaces()
{
public int getFillFaces() {
return this.fillFaces;
}
/**
* @return the fillRecursion
*/
public int getFillRecursion()
{
public int getFillRecursion() {
return this.fillRecursion;
}
public ErosionPreset getInverted()
{
public ErosionPreset getInverted() {
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
*/
public class ExtrudeBrush extends Brush
{
public class ExtrudeBrush extends Brush {
private double trueCircle;
/**
*
*/
public ExtrudeBrush()
{
public ExtrudeBrush() {
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 double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
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);
for (int z = -brushSize; z <= brushSize; z++)
{
if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared)
{
for (int z = -brushSize; z <= brushSize; z++) {
if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared) {
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;
undo = this.perform(
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);
}
private void extrudeNorthOrSouth(final SnipeData v, boolean isSouth)
{
private void extrudeNorthOrSouth(final SnipeData v, boolean isSouth) {
final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
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);
for (int y = -brushSize; y <= brushSize; y++)
{
if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared)
{
for (int y = -brushSize; y <= brushSize; y++) {
if ((xSquared + Math.pow(y, 2)) <= brushSizeSquared) {
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;
undo = this.perform(
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);
}
private void extrudeEastOrWest(final SnipeData v, boolean isEast)
{
private void extrudeEastOrWest(final SnipeData v, boolean isEast) {
final int brushSize = v.getBrushSize();
final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
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);
for (int z = -brushSize; z <= brushSize; z++)
{
if ((ySquared + Math.pow(z, 2)) <= brushSizeSquared)
{
for (int z = -brushSize; z <= brushSize; z++) {
if ((ySquared + Math.pow(z, 2)) <= brushSizeSquared) {
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;
undo = this.perform(
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")
private Undo perform(final Block b1, final Block b2, final SnipeData v, final Undo undo)
{
if (v.getVoxelList().contains(b1.getBlockData()))
{
private Undo perform(final Block b1, final Block b2, final SnipeData v, final Undo undo) {
if (v.getVoxelList().contains(b1.getBlockData())) {
undo.put(b2);
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());
@ -125,15 +106,12 @@ public class ExtrudeBrush extends Brush
return undo;
}
private void selectExtrudeMethod(final SnipeData v, final BlockFace blockFace, final boolean towardsUser)
{
if (blockFace == null || v.getVoxelHeight() == 0)
{
private void selectExtrudeMethod(final SnipeData v, final BlockFace blockFace, final boolean towardsUser) {
if (blockFace == null || v.getVoxelHeight() == 0) {
return;
}
boolean tempDirection = towardsUser;
switch (blockFace)
{
switch (blockFace) {
case DOWN:
tempDirection = !towardsUser;
case UP:
@ -155,20 +133,17 @@ public class ExtrudeBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.selectExtrudeMethod(v, this.getTargetBlock().getFace(this.getLastBlock()), false);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.selectExtrudeMethod(v, this.getTargetBlock().getFace(this.getLastBlock()), true);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
vm.height();
@ -178,46 +153,33 @@ public class ExtrudeBrush extends Brush
}
@Override
public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) {
for (int i = 1; i < par.length; i++) {
final String parameter = par[i];
try
{
if (parameter.equalsIgnoreCase("info"))
{
try {
if (parameter.equalsIgnoreCase("info")) {
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)");
return;
}
else if (parameter.startsWith("true"))
{
} else if (parameter.startsWith("true")) {
this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
}
else if (parameter.startsWith("false"))
{
} else if (parameter.startsWith("false")) {
this.trueCircle = 0;
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.");
return;
}
}
catch (final Exception exception)
{
} catch (final Exception exception) {
v.sendMessage(ChatColor.RED + "Incorrect parameter \"" + parameter + "\"; use the \"info\" parameter.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.extrude";
}
}

Datei anzeigen

@ -11,8 +11,7 @@ import org.bukkit.block.Block;
/**
* @author Voxel
*/
public class FillDownBrush extends PerformBrush
{
public class FillDownBrush extends PerformBrush {
private double trueCircle = 0;
private boolean fillLiquid = true;
private boolean fromExisting = false;
@ -20,51 +19,43 @@ public class FillDownBrush extends PerformBrush
/**
*
*/
public FillDownBrush()
{
public FillDownBrush() {
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 double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2);
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);
for (int z = -brushSize; z <= brushSize; z++)
{
if (currentXSquared + Math.pow(z, 2) <= brushSizeSquared)
{
int y = 0;
boolean found = false;
if(this.fromExisting) {
for(y = -v.getVoxelHeight(); y < v.getVoxelHeight(); y++) {
final Block currentBlock = this.getWorld().getBlockAt(
targetBlock.getX() + x,
targetBlock.getY() + y,
targetBlock.getZ() + z);
if(!currentBlock.isEmpty()) {
found = true;
break;
}
}
if(!found) continue;
y--;
}
for (; y >= -targetBlock.getY(); --y)
{
for (int z = -brushSize; z <= brushSize; z++) {
if (currentXSquared + Math.pow(z, 2) <= brushSizeSquared) {
int y = 0;
boolean found = false;
if (this.fromExisting) {
for (y = -v.getVoxelHeight(); y < v.getVoxelHeight(); y++) {
final Block currentBlock = this.getWorld().getBlockAt(
targetBlock.getX() + x,
targetBlock.getY() + y,
targetBlock.getZ() + z);
if (!currentBlock.isEmpty()) {
found = true;
break;
}
}
if (!found) continue;
y--;
}
for (; y >= -targetBlock.getY(); --y) {
final AsyncBlock currentBlock = this.getWorld().getBlockAt(
targetBlock.getX() + x,
targetBlock.getY() + y,
targetBlock.getZ() + z);
if (currentBlock.isEmpty() || (fillLiquid && currentBlock.isLiquid()))
{
if (currentBlock.isEmpty() || (fillLiquid && currentBlock.isLiquid())) {
this.current.perform(currentBlock);
} else
{
} else {
break;
}
}
@ -76,31 +67,25 @@ public class FillDownBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.fillDown(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.fillDown(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
if (par[i].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) {
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 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 -e -- Fills into only existing blocks. (Toggle)");
return;
}
else if (par[i].equalsIgnoreCase("true"))
{
} else if (par[i].equalsIgnoreCase("true")) {
this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
}
else if (par[i].equalsIgnoreCase("false"))
{
} else if (par[i].equalsIgnoreCase("false")) {
this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
}
else if (par[i].equalsIgnoreCase("all"))
{
} else if (par[i].equalsIgnoreCase("all")) {
this.fillLiquid = true;
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;
v.setReplaceId(BlockTypes.AIR.getInternalId());
v.sendMessage(ChatColor.AQUA + "Now only filling air.");
}
else if (par[i].equalsIgnoreCase("-e"))
{
this.fromExisting = !this.fromExisting;
v.sendMessage(ChatColor.AQUA + "Now filling down from " + ((this.fromExisting) ? "existing" : "all") + " blocks.");
}
else
{
} else if (par[i].equalsIgnoreCase("-e")) {
this.fromExisting = !this.fromExisting;
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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.SnipeData;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Material;
/**
* @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_FLOOR_LEVEL = 8;
private int waterLevel = DEFAULT_WATER_LEVEL;
@ -20,30 +18,20 @@ public class FlatOceanBrush extends Brush
/**
*
*/
public FlatOceanBrush()
{
public FlatOceanBrush() {
this.setName("FlatOcean");
}
@SuppressWarnings("deprecation")
private void flatOcean(final AsyncChunk chunk)
{
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++)
{
if (y <= this.floorLevel)
{
private void flatOcean(final AsyncChunk chunk) {
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++) {
if (y <= this.floorLevel) {
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);
}
else
{
} else {
chunk.getBlock(x, y, z).setType(Material.AIR);
}
}
@ -52,14 +40,12 @@ public class FlatOceanBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.flatOcean(this.getWorld().getChunkAt(this.getTargetBlock()));
}
@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.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)));
@ -72,8 +58,7 @@ public class FlatOceanBrush extends Brush
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.custom(ChatColor.RED + "THIS BRUSH DOES NOT UNDO");
vm.custom(ChatColor.GREEN + "Water level set to " + this.waterLevel);
@ -81,35 +66,26 @@ public class FlatOceanBrush extends Brush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; 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 + "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", ""));
if (newWaterLevel < this.floorLevel)
{
if (newWaterLevel < this.floorLevel) {
newWaterLevel = this.floorLevel + 1;
}
this.waterLevel = newWaterLevel;
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", ""));
if (newFloorLevel > this.waterLevel)
{
if (newFloorLevel > this.waterLevel) {
newFloorLevel = this.waterLevel - 1;
if (newFloorLevel == 0)
{
if (newFloorLevel == 0) {
newFloorLevel = 1;
this.waterLevel = 2;
}
@ -121,8 +97,7 @@ public class FlatOceanBrush extends Brush
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.flatocean";
}
}

Datei anzeigen

@ -1,18 +1,17 @@
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.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.Material;
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
/**
@ -20,8 +19,7 @@ import org.bukkit.block.Block;
*
* @author Ghost8700 @ Voxel
*/
public class GenerateTreeBrush extends Brush
{
public class GenerateTreeBrush extends Brush {
// Tree Variables.
private Random randGenerator = new Random();
private ArrayList<Block> branchBlocks = new ArrayList<>();
@ -50,8 +48,7 @@ public class GenerateTreeBrush extends Brush
/**
*
*/
public GenerateTreeBrush()
{
public GenerateTreeBrush() {
this.setName("Generate Tree");
}
@ -85,8 +82,7 @@ public class GenerateTreeBrush extends Brush
// Branch Creation based on direction chosen from the parameters passed.
@SuppressWarnings("deprecation")
private void branchCreate(final int xDirection, final int zDirection)
{
private void branchCreate(final int xDirection, final int zDirection) {
// Sets branch origin.
final int originX = blockPositionX;
@ -98,28 +94,23 @@ public class GenerateTreeBrush extends Brush
final int zPreference = this.randGenerator.nextInt(60) + 20;
// 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.
if (this.randGenerator.nextInt(100) < xPreference)
{
if (this.randGenerator.nextInt(100) < xPreference) {
blockPositionX = blockPositionX + 1 * xDirection;
}
if (this.randGenerator.nextInt(100) < zPreference)
{
if (this.randGenerator.nextInt(100) < zPreference) {
blockPositionZ = blockPositionZ + 1 * zDirection;
}
// 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);
}
// 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));
}
@ -135,8 +126,7 @@ public class GenerateTreeBrush extends Brush
}
@SuppressWarnings("deprecation")
private void leafNodeCreate()
{
private void leafNodeCreate() {
// Generates the node size.
final int nodeRadius = this.randGenerator.nextInt(this.nodeMax - this.nodeMin + 1) + this.nodeMin;
final double bSquared = Math.pow(nodeRadius + 0.5, 2);
@ -145,105 +135,77 @@ public class GenerateTreeBrush extends Brush
blockPositionY = blockPositionY - 2;
for (int z = nodeRadius; z >= 0; z--)
{
for (int z = nodeRadius; z >= 0; z--) {
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);
for (int y = nodeRadius; y >= 0; y--)
{
if ((xSquared + Math.pow(y, 2) + zSquared) <= bSquared)
{
for (int y = nodeRadius; y >= 0; y--) {
if ((xSquared + Math.pow(y, 2) + zSquared) <= bSquared) {
// 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 (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.
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));
}
// Creates block.
this.clampY(blockPositionX + x, blockPositionY + y, blockPositionZ + z).setType(this.leafType);
}
}
if (this.randGenerator.nextInt(100) >= 30)
{
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ - z).isEmpty())
{
if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY + y, blockPositionZ - z)))
{
if (this.randGenerator.nextInt(100) >= 30) {
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ - z).isEmpty()) {
if (!isLeave(this.getBlockType(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);
}
}
if (this.randGenerator.nextInt(100) >= 30)
{
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY + y, blockPositionZ + z).isEmpty())
{
if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY + y, blockPositionZ + z)))
{
if (this.randGenerator.nextInt(100) >= 30) {
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY + y, blockPositionZ + z).isEmpty()) {
if (!isLeave(this.getBlockType(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);
}
}
if (this.randGenerator.nextInt(100) >= 30)
{
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY + y, blockPositionZ - z).isEmpty())
{
if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY + y, blockPositionZ - z)))
{
if (this.randGenerator.nextInt(100) >= 30) {
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY + y, blockPositionZ - z).isEmpty()) {
if (!isLeave(this.getBlockType(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);
}
}
if (this.randGenerator.nextInt(100) >= 30)
{
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY - y, blockPositionZ + z).isEmpty())
{
if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY - y, blockPositionZ + z)))
{
if (this.randGenerator.nextInt(100) >= 30) {
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY - y, blockPositionZ + z).isEmpty()) {
if (!isLeave(this.getBlockType(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);
}
}
if (this.randGenerator.nextInt(100) >= 30)
{
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY - y, blockPositionZ - z).isEmpty())
{
if (!isLeave(this.getBlockType(blockPositionX + x, blockPositionY - y, blockPositionZ - z)))
{
if (this.randGenerator.nextInt(100) >= 30) {
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY - y, blockPositionZ - z).isEmpty()) {
if (!isLeave(this.getBlockType(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);
}
}
if (this.randGenerator.nextInt(100) >= 30)
{
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY - y, blockPositionZ + z).isEmpty())
{
if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY - y, blockPositionZ + z)))
{
if (this.randGenerator.nextInt(100) >= 30) {
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY - y, blockPositionZ + z).isEmpty()) {
if (!isLeave(this.getBlockType(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);
}
}
if (this.randGenerator.nextInt(100) >= 30)
{
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY - y, blockPositionZ - z).isEmpty())
{
if (!isLeave(this.getBlockType(blockPositionX - x, blockPositionY - y, blockPositionZ - z)))
{
if (this.randGenerator.nextInt(100) >= 30) {
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY - y, blockPositionZ - z).isEmpty()) {
if (!isLeave(this.getBlockType(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);
@ -262,8 +224,7 @@ public class GenerateTreeBrush extends Brush
* @param zDirection
*/
@SuppressWarnings("deprecation")
private void rootCreate(final int xDirection, final int zDirection)
{
private void rootCreate(final int xDirection, final int zDirection) {
// Sets Origin.
final int originX = blockPositionX;
final int originY = blockPositionY;
@ -276,11 +237,9 @@ public class GenerateTreeBrush extends Brush
// 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.
for (int t = 0; t < this.thickness - 1; t++)
{
for (int t = 0; t < this.thickness - 1; t++) {
blockPositionX = blockPositionX + xDirection;
blockPositionZ = blockPositionZ + zDirection;
}
@ -289,57 +248,44 @@ public class GenerateTreeBrush extends Brush
final int xPreference = 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.
// If not solid then...
// 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));
// Place log block.
this.clampY(blockPositionX, blockPositionY, blockPositionZ).setType(this.woodType);
}
else
{
} else {
// If solid then...
// End loop
break;
}
// 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.
blockPositionY = blockPositionY - 1;
if (this.rootFloat)
{
if (this.randGenerator.nextInt(100) < xPreference)
{
if (this.rootFloat) {
if (this.randGenerator.nextInt(100) < xPreference) {
blockPositionX = blockPositionX + xDirection;
}
if (this.randGenerator.nextInt(100) < zPreference)
{
if (this.randGenerator.nextInt(100) < zPreference) {
blockPositionZ = blockPositionZ + zDirection;
}
}
}
else
{
} else {
// If solid then move.
if (this.randGenerator.nextInt(100) < xPreference)
{
if (this.randGenerator.nextInt(100) < xPreference) {
blockPositionX = blockPositionX + xDirection;
}
if (this.randGenerator.nextInt(100) < zPreference)
{
if (this.randGenerator.nextInt(100) < zPreference) {
blockPositionZ = blockPositionZ + zDirection;
}
// 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;
}
}
@ -353,8 +299,7 @@ public class GenerateTreeBrush extends Brush
}
}
private void rootGen()
{
private void rootGen() {
// Quadrant 1
this.rootCreate(1, 1);
@ -369,50 +314,38 @@ public class GenerateTreeBrush extends Brush
}
@SuppressWarnings("deprecation")
private void trunkCreate()
{
private void trunkCreate() {
// Creates true circle discs of the set size using the wood type selected.
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);
for (int z = this.thickness; z >= 0; z--)
{
if ((xSquared + Math.pow(z, 2)) <= bSquared)
{
for (int z = this.thickness; z >= 0; z--) {
if ((xSquared + Math.pow(z, 2)) <= bSquared) {
// 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.
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));
}
// Creates block.
this.clampY(blockPositionX + x, blockPositionY, blockPositionZ + z).setType(this.woodType);
}
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY, blockPositionZ - z).isEmpty())
{
if (!isLog(this.getBlockType(blockPositionX + x, blockPositionY, blockPositionZ - z)))
{
if (this.getWorld().getBlockAt(blockPositionX + x, blockPositionY, blockPositionZ - z).isEmpty()) {
if (!isLog(this.getBlockType(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);
}
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY, blockPositionZ + z).isEmpty())
{
if (!isLog(this.getBlockType(blockPositionX - x, blockPositionY, blockPositionZ + z)))
{
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY, blockPositionZ + z).isEmpty()) {
if (!isLog(this.getBlockType(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);
}
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY, blockPositionZ - z).isEmpty())
{
if (!isLog(this.getBlockType(blockPositionX - x, blockPositionY, blockPositionZ - z)))
{
if (this.getWorld().getBlockAt(blockPositionX - x, blockPositionY, blockPositionZ - z).isEmpty()) {
if (!isLog(this.getBlockType(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);
@ -423,11 +356,10 @@ public class GenerateTreeBrush extends Brush
}
/*
*
*
* Code Concerning Trunk Generation
*/
private void trunkGen()
{
private void trunkGen() {
// Sets Origin
final int originX = blockPositionX;
final int originY = blockPositionY;
@ -442,38 +374,30 @@ public class GenerateTreeBrush extends Brush
// Sets direction.
int xDirection = 1;
if (this.randGenerator.nextInt(100) < 50)
{
if (this.randGenerator.nextInt(100) < 50) {
xDirection = -1;
}
int zDirection = 1;
if (this.randGenerator.nextInt(100) < 50)
{
if (this.randGenerator.nextInt(100) < 50) {
zDirection = -1;
}
// Generates a height for trunk.
int height = this.randGenerator.nextInt(this.heightMaximum - this.heightMininmum + 1) + this.heightMininmum;
for (int p = 0; p < height; p++)
{
if (p > 3)
{
if (this.randGenerator.nextInt(100) <= this.twistChance)
{
for (int p = 0; p < height; p++) {
if (p > 3) {
if (this.randGenerator.nextInt(100) <= this.twistChance) {
xDirection *= -1;
}
if (this.randGenerator.nextInt(100) <= this.twistChance)
{
if (this.randGenerator.nextInt(100) <= this.twistChance) {
zDirection *= -1;
}
if (this.randGenerator.nextInt(100) < xPreference)
{
if (this.randGenerator.nextInt(100) < xPreference) {
blockPositionX += xDirection;
}
if (this.randGenerator.nextInt(100) < zPreference)
{
if (this.randGenerator.nextInt(100) < zPreference) {
blockPositionZ += zDirection;
}
}
@ -505,38 +429,30 @@ public class GenerateTreeBrush extends Brush
// Sets direction.
xDirection = 1;
if (this.randGenerator.nextInt(100) < 50)
{
if (this.randGenerator.nextInt(100) < 50) {
xDirection = -1;
}
zDirection = 1;
if (this.randGenerator.nextInt(100) < 50)
{
if (this.randGenerator.nextInt(100) < 50) {
zDirection = -1;
}
// Generates a height for trunk.
height = this.randGenerator.nextInt(this.heightMaximum - this.heightMininmum + 1) + this.heightMininmum;
if (height > 4)
{
for (int p = 0; p < height; p++)
{
if (this.randGenerator.nextInt(100) <= this.twistChance)
{
if (height > 4) {
for (int p = 0; p < height; p++) {
if (this.randGenerator.nextInt(100) <= this.twistChance) {
xDirection *= -1;
}
if (this.randGenerator.nextInt(100) <= this.twistChance)
{
if (this.randGenerator.nextInt(100) <= this.twistChance) {
zDirection *= -1;
}
if (this.randGenerator.nextInt(100) < xPreference)
{
if (this.randGenerator.nextInt(100) < xPreference) {
blockPositionX = blockPositionX + 1 * xDirection;
}
if (this.randGenerator.nextInt(100) < zPreference)
{
if (this.randGenerator.nextInt(100) < zPreference) {
blockPositionZ = blockPositionZ + 1 * zDirection;
}
@ -556,8 +472,7 @@ public class GenerateTreeBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.undo = new Undo();
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.
// 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();
blockPositionY = block.getY();
blockPositionZ = block.getZ();
@ -589,28 +503,22 @@ public class GenerateTreeBrush extends Brush
// The Powder currently does nothing extra.
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.arrow(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
final String parameter = par[i];
try
{
if (parameter.equalsIgnoreCase("info"))
{
try {
if (parameter.equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "This brush takes the following parameters:");
v.sendMessage(ChatColor.AQUA + "lt# - leaf type (data value)");
v.sendMessage(ChatColor.AQUA + "wt# - wood type (data value)");
@ -624,8 +532,7 @@ public class GenerateTreeBrush extends Brush
return;
}
if (parameter.equalsIgnoreCase("info2"))
{
if (parameter.equalsIgnoreCase("info2")) {
v.sendMessage(ChatColor.GOLD + "This brush takes the following parameters:");
v.sendMessage(ChatColor.AQUA + "minr# - minimum 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");
return;
}
if (parameter.startsWith("lt"))
{ // Leaf Type
if (parameter.startsWith("lt")) { // Leaf Type
this.leafType = BukkitAdapter.adapt(BlockTypes.parse(parameter.replace("lt", "")));
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", "")));
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", ""));
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", ""));
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", ""));
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", ""));
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", ""));
if (this.minRoots > this.maxRoots)
{
if (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!");
}
else
{
} else {
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", ""));
if (this.minRoots > this.maxRoots)
{
if (this.minRoots > this.maxRoots) {
this.maxRoots = this.minRoots;
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);
}
}
else if (parameter.startsWith("ts"))
{ // Trunk Slope Chance
} else if (parameter.startsWith("ts")) { // Trunk Slope Chance
this.slopeChance = Integer.parseInt(parameter.replace("ts", ""));
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", ""));
if (this.heightMininmum > this.heightMaximum)
{
if (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!");
}
else
{
} else {
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", ""));
if (this.heightMininmum > this.heightMaximum)
{
if (this.heightMininmum > this.heightMaximum) {
this.heightMaximum = this.heightMininmum;
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);
}
}
else if (parameter.startsWith("bl"))
{ // Branch Length
} else if (parameter.startsWith("bl")) { // Branch Length
this.branchLength = Integer.parseInt(parameter.replace("bl", ""));
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", ""));
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", ""));
v.sendMessage(ChatColor.BLUE + "Leaf Min Thickness set to " + this.nodeMin + " (Default 3)");
// -------
// Presets
// -------
}
else if (parameter.startsWith("default"))
{ // Default settings.
} else if (parameter.startsWith("default")) { // Default settings.
this.leafType = Material.OAK_LEAVES;
this.woodType = Material.OAK_WOOD;
this.rootFloat = false;
@ -759,14 +625,10 @@ public class GenerateTreeBrush extends Brush
this.nodeMax = 4;
this.nodeMin = 3;
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.");
}
}
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.");
}
@ -774,8 +636,7 @@ public class GenerateTreeBrush extends Brush
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.generatetree";
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -9,14 +9,11 @@ import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
/**
* Moves a selection blockPositionY a certain amount.
@ -24,8 +21,7 @@ import java.util.TreeSet;
*
* @author MikeMatrix
*/
public class MoveBrush extends Brush
{
public class MoveBrush extends Brush {
/**
* Saved direction.
*/
@ -38,8 +34,7 @@ public class MoveBrush extends Brush
/**
*
*/
public MoveBrush()
{
public MoveBrush() {
this.setName("Move");
}
@ -51,10 +46,8 @@ public class MoveBrush extends Brush
* @param direction
*/
@SuppressWarnings("deprecation")
private void moveSelection(final SnipeData v, final Selection selection, final int[] direction)
{
if (selection.getBlockStates().size() > 0)
{
private void moveSelection(final SnipeData v, final Selection selection, final int[] direction) {
if (selection.getBlockStates().size() > 0) {
final AsyncWorld world = selection.getBlockStates().get(0).getWorld();
final Undo undo = new Undo();
@ -67,36 +60,28 @@ public class MoveBrush extends Brush
movedLocation2.add(direction[0], direction[1], direction[2]);
newSelection.setLocation1(movedLocation1);
newSelection.setLocation2(movedLocation2);
try
{
try {
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!");
}
for (final BlockState blockState : selection.getBlockStates())
{
for (final BlockState blockState : selection.getBlockStates()) {
undoSet.add(blockState.getBlock());
}
for (final BlockState blockState : newSelection.getBlockStates())
{
for (final BlockState blockState : newSelection.getBlockStates()) {
undoSet.add(blockState.getBlock());
}
for (final Block block : undoSet)
{
for (final Block block : undoSet) {
undo.put(block);
}
v.owner().storeUndo(undo);
for (final BlockState blockState : selection.getBlockStates())
{
for (final BlockState blockState : selection.getBlockStates()) {
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]);
affectedBlock.setTypeId(blockState.getTypeId());
affectedBlock.setPropertyId(blockState.getPropertyId());
@ -105,67 +90,51 @@ public class MoveBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
if (this.selection == null)
{
protected final void arrow(final SnipeData v) {
if (this.selection == null) {
this.selection = new Selection();
}
this.selection.setLocation1(this.getTargetBlock().getLocation());
v.getVoxelMessage().brushMessage("Point 1 set.");
try
{
if (this.selection.calculateRegion())
{
try {
if (this.selection.calculateRegion()) {
this.moveSelection(v, this.selection, this.moveDirections);
this.selection = null;
}
}
catch (final Exception exception)
{
} catch (final Exception exception) {
v.sendMessage(exception.getMessage());
}
}
@Override
protected final void powder(final SnipeData v)
{
if (this.selection == null)
{
protected final void powder(final SnipeData v) {
if (this.selection == null) {
this.selection = new Selection();
}
this.selection.setLocation2(this.getTargetBlock().getLocation());
v.getVoxelMessage().brushMessage("Point 2 set.");
try
{
if (this.selection.calculateRegion())
{
try {
if (this.selection.calculateRegion()) {
this.moveSelection(v, this.selection, this.moveDirections);
this.selection = null;
}
}
catch (final Exception exception)
{
} catch (final Exception exception) {
v.sendMessage(exception.getMessage());
}
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
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]);
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
if (par[i].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) {
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 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 + "Use arrow and gunpowder to define two points.");
}
if (par[i].equalsIgnoreCase("reset"))
{
if (par[i].equalsIgnoreCase("reset")) {
this.moveDirections[0] = 0;
this.moveDirections[1] = 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 + "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));
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));
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));
v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]);
}
}
}
@Override
public String getPermissionNode() {
return "voxelsniper.brush.move";
}
/**
* Selection Helper class.
*
* @author MikeMatrix
*/
private class Selection
{
private class Selection {
/**
* Maximum amount of Blocks allowed blockPositionY the Selection.
*/
@ -230,29 +197,22 @@ public class MoveBrush extends Brush
* @return boolean success.
* @throws Exception Message to be sent to the player.
*/
public boolean calculateRegion() throws Exception
{
if (this.location1 != null && this.location2 != null)
{
if (this.location1.getWorld().equals(this.location2.getWorld()))
{
public boolean calculateRegion() throws Exception {
if (this.location1 != null && this.location2 != null) {
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 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 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 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.");
}
final AsyncWorld world = (AsyncWorld) this.location1.getWorld();
for (int y = lowY; y <= highY; y++)
{
for (int x = lowX; x <= highX; x++)
{
for (int z = lowZ; z <= highZ; z++)
{
for (int y = lowY; y <= highY; y++) {
for (int x = lowX; x <= highX; x++) {
for (int z = lowZ; z <= highZ; z++) {
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.
*/
public ArrayList<AsyncBlockState> getBlockStates()
{
public ArrayList<AsyncBlockState> getBlockStates() {
return this.blockStates;
}
/**
* @return Location
*/
public Location getLocation1()
{
public Location getLocation1() {
return this.location1;
}
/**
* @param location1
*/
public void setLocation1(final Location location1)
{
public void setLocation1(final Location location1) {
this.location1 = location1;
}
/**
* @return Location
*/
public Location getLocation2()
{
public Location getLocation2() {
return this.location2;
}
/**
* @param location2
*/
public void setLocation2(final Location location2)
{
public void setLocation2(final Location 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
*/
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_MIN = 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)");
}
private int getHeight(final int bx, final int bz)
{
for (int y = this.getWorld().getHighestBlockYAt(bx, bz); y > 0; y--)
{
private int getHeight(final int bx, final int bz) {
for (int y = this.getWorld().getHighestBlockYAt(bx, bz); y > 0; y--) {
final Material material = this.clampY(bx, y, bz).getType();
if (material.isSolid())
{
if (material.isSolid()) {
return y;
}
}
@ -48,8 +43,7 @@ public class OceanBrush extends Brush
* @param v
* @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 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 maxZ = (int) Math.floor((this.getTargetBlock().getZ() + v.getBrushSize()));
for (int x = minX; x <= maxX; x++)
{
for (int z = minZ; z <= maxZ; z++)
{
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
final int currentHeight = getHeight(x, z);
final int wLevelDiff = currentHeight - (this.waterLevel - 1);
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);
// 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);
if (!block.getType().equals(Material.AIR))
{
if (!block.getType().equals(Material.AIR)) {
undo.put(block);
block.setType(Material.AIR);
}
}
// 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);
if (!block.getType().equals(Material.WATER))
{
if (!block.getType().equals(Material.WATER)) {
// 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);
}
block.setType(Material.WATER);
@ -94,11 +81,9 @@ public class OceanBrush extends Brush
}
// 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);
if (block.getTypeId() != v.getVoxelId())
{
if (block.getTypeId() != v.getVoxelId()) {
undo.put(block);
block.setTypeId(v.getVoxelId());
}
@ -108,57 +93,44 @@ public class OceanBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
Undo undo = new Undo();
this.oceanator(v, undo);
v.owner().storeUndo(undo);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
arrow(v);
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 0; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 0; i < par.length; i++) {
final String parameter = par[i];
try
{
if (parameter.equalsIgnoreCase("info"))
{
try {
if (parameter.equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.BLUE + "Parameters:");
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)");
}
else if (parameter.equalsIgnoreCase("-wlevel"))
{
if ((i + 1) >= par.length)
{
} else if (parameter.equalsIgnoreCase("-wlevel")) {
if ((i + 1) >= par.length) {
v.sendMessage(ChatColor.RED + "Missing parameter. Correct syntax: -wlevel [#] (e.g. -wlevel 64)");
continue;
}
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.");
continue;
}
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
}
else if (parameter.equalsIgnoreCase("-cfloor") || parameter.equalsIgnoreCase("-coverfloor"))
{
if ((i + 1) >= par.length)
{
} else if (parameter.equalsIgnoreCase("-cfloor") || parameter.equalsIgnoreCase("-coverfloor")) {
if ((i + 1) >= par.length) {
v.sendMessage(ChatColor.RED + "Missing parameter. Correct syntax: -cfloor [y|n] (e.g. -cfloor y)");
continue;
}
@ -166,9 +138,7 @@ public class OceanBrush extends Brush
this.coverFloor = par[++i].equalsIgnoreCase("y");
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));
exception.printStackTrace();
}
@ -176,16 +146,14 @@ public class OceanBrush extends Brush
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
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 + String.format("Floor cover %s.", ChatColor.GREEN + (this.coverFloor ? "enabled" : "disabled")));
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.ocean";
}
}

Datei anzeigen

@ -9,7 +9,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import org.bukkit.Material;
/**
* 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
// column is valid if it has no solid block right above the clicked layer
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 ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared) {
for (int y = this.getTargetBlock().getY(); y > 0; y--) {
// check for surface
final int layerBlockId =
this.getBlockIdAt(this.getTargetBlock().getX() + x, y,
this.getTargetBlock().getZ() + z);
this.getBlockIdAt(this.getTargetBlock().getX() + x, y,
this.getTargetBlock().getZ() + z);
if (!isIgnoredBlock(layerBlockId)) {
for (int currentDepth = y;
y - currentDepth < depth; currentDepth--) {
final int currentBlockId =
this.getBlockIdAt(this.getTargetBlock().getX() + x,
currentDepth, this.getTargetBlock().getZ() + z);
this.getBlockIdAt(this.getTargetBlock().getX() + x,
currentDepth, this.getTargetBlock().getZ() + z);
if (isOverrideableMaterial(currentBlockId)) {
this.current.perform(
this.clampY(this.getTargetBlock().getX() + x,
currentDepth, this.getTargetBlock().getZ() + z));
this.clampY(this.getTargetBlock().getX() + x,
currentDepth, this.getTargetBlock().getZ() + z));
}
}
break;
@ -69,7 +68,8 @@ public class OverlayBrush extends PerformBrush {
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);
switch (type.getInternalId()) {
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();
if (allBlocks && !(mat.isAir())) {
return true;
@ -102,32 +103,32 @@ public class OverlayBrush extends PerformBrush {
for (int y = this.getTargetBlock().getY();
y > 0 && !surfaceFound; y--) { // start scanning from the height you clicked at
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))
<= brushSizeSquared) { // if inside of the column...
<= brushSizeSquared) { // if inside of the column...
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
.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.
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
.getBlockType(this.getTargetBlock().getX() + x, y,
this.getTargetBlock().getZ() + z)));
.getBlockType(this.getTargetBlock().getX() + x, y,
this.getTargetBlock().getZ() + z)));
BlockMaterial mat = type.getMaterial();
if (mat.isSolid() && mat.isFullCube() && !mat
.hasContainer()) {
.hasContainer()) {
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
this.clampY(this.getTargetBlock().getX() + x,
y + d, this.getTargetBlock().getZ()
+ z)); // fills down as many layers as you specify
// in parameters
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;
@ -135,12 +136,12 @@ public class OverlayBrush extends PerformBrush {
} else {
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.clampY(this.getTargetBlock().getX() + x, y + d,
this.getTargetBlock().getZ()
+ z)); // fills down as many layers as you specify in
// parameters
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;
}
@ -156,29 +157,33 @@ public class OverlayBrush extends PerformBrush {
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);
}
@Override protected final void powder(final SnipeData v) {
@Override
protected final void powder(final SnipeData 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.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++) {
final String parameter = par[i];
if (parameter.equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Overlay brush parameters:");
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
+ "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;
}
if (parameter.startsWith("d")) {
@ -199,15 +204,16 @@ public class OverlayBrush extends PerformBrush {
} else if (parameter.startsWith("some")) {
this.allBlocks = false;
v.sendMessage(
ChatColor.BLUE + "Will overlay only natural block types." + this.depth);
ChatColor.BLUE + "Will overlay only natural block types." + this.depth);
} else {
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";
}
}

Datei anzeigen

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

Datei anzeigen

@ -26,8 +26,7 @@ import java.util.Random;
* @author Deamon
* @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 TICKS_PER_SECOND = 20;
private static final int INFINIPUNISH_SIZE = -3;
@ -44,16 +43,13 @@ public class PunishBrush extends PerformBrush
/**
* Default Constructor.
*/
public PunishBrush()
{
public PunishBrush() {
this.setName("Punish");
}
@SuppressWarnings("deprecation")
private void applyPunishment(final LivingEntity entity, final SnipeData v)
{
switch (this.punishment)
{
private void applyPunishment(final LivingEntity entity, final SnipeData v) {
switch (this.punishment) {
case FIRE:
entity.setFireTicks(PunishBrush.TICKS_PER_SECOND * this.punishDuration);
break;
@ -153,21 +149,16 @@ public class PunishBrush extends PerformBrush
entity.setVelocity(direction);
break;
case HYPNO:
if (entity instanceof Player)
{
if (entity instanceof Player) {
final Location location = entity.getLocation();
Location target = location.clone();
for (int z = this.punishLevel; z >= -this.punishLevel; z--)
{
for (int x = this.punishLevel; x >= -this.punishLevel; x--)
{
for (int y = this.punishLevel; y >= -this.punishLevel; y--)
{
for (int z = this.punishLevel; z >= -this.punishLevel; z--) {
for (int x = this.punishLevel; x >= -this.punishLevel; x--) {
for (int y = this.punishLevel; y >= -this.punishLevel; y--) {
target.setX(location.getX() + x);
target.setY(location.getY() + y);
target.setZ(location.getZ() + z);
if (this.hypnoAffectLandscape && target.getBlock().isEmpty())
{
if (this.hypnoAffectLandscape && target.getBlock().isEmpty()) {
continue;
}
target = location.clone();
@ -187,10 +178,8 @@ public class PunishBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
if (!v.owner().getPlayer().hasPermission("voxelsniper.punish"))
{
protected final void arrow(final SnipeData v) {
if (!v.owner().getPlayer().hasPermission("voxelsniper.punish")) {
v.sendMessage("The server says no!");
return;
}
@ -198,11 +187,9 @@ public class PunishBrush extends PerformBrush
this.punishDuration = v.getVoxelHeight();
this.punishLevel = v.getcCen();
if (this.specificPlayer)
{
if (this.specificPlayer) {
final Player punishedPlayer = Bukkit.getPlayer(this.punishPlayerName);
if (punishedPlayer == null)
{
if (punishedPlayer == null) {
v.sendMessage("No player " + this.punishPlayerName + " found.");
return;
}
@ -216,29 +203,20 @@ public class PunishBrush extends PerformBrush
final List<LivingEntity> entities = v.getWorld().getLivingEntities();
int numPunishApps = 0;
for (final LivingEntity entity : entities)
{
if (v.owner().getPlayer() != entity || hitsSelf)
{
if (v.getBrushSize() >= 0)
{
try
{
if (entity.getLocation().distanceSquared(targetLocation) <= brushSizeSquare)
{
for (final LivingEntity entity : entities) {
if (v.owner().getPlayer() != entity || hitsSelf) {
if (v.getBrushSize() >= 0) {
try {
if (entity.getLocation().distanceSquared(targetLocation) <= brushSizeSquare) {
numPunishApps++;
this.applyPunishment(entity, v);
}
}
catch (final Exception exception)
{
} catch (final Exception exception) {
exception.printStackTrace();
v.sendMessage("An error occured.");
return;
}
}
else if (v.getBrushSize() == PunishBrush.INFINIPUNISH_SIZE)
{
} else if (v.getBrushSize() == PunishBrush.INFINIPUNISH_SIZE) {
numPunishApps++;
this.applyPunishment(entity, v);
}
@ -248,10 +226,8 @@ public class PunishBrush extends PerformBrush
}
@Override
protected final void powder(final SnipeData v)
{
if (!v.owner().getPlayer().hasPermission("voxelsniper.punish"))
{
protected final void powder(final SnipeData v) {
if (!v.owner().getPlayer().hasPermission("voxelsniper.punish")) {
v.sendMessage("The server says no!");
return;
}
@ -261,10 +237,8 @@ public class PunishBrush extends PerformBrush
final List<LivingEntity> entities = v.getWorld().getLivingEntities();
for (final LivingEntity entity : entities)
{
if (entity.getLocation().distanceSquared(targetLocation) < brushSizeSquare)
{
for (final LivingEntity entity : entities) {
if (entity.getLocation().distanceSquared(targetLocation) < brushSizeSquare) {
entity.setFireTicks(0);
entity.removePotionEffect(PotionEffectType.BLINDNESS);
entity.removePotionEffect(PotionEffectType.CONFUSION);
@ -276,8 +250,7 @@ public class PunishBrush extends PerformBrush
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.custom(ChatColor.GREEN + "Punishment: " + this.punishment.toString());
vm.size();
@ -285,14 +258,11 @@ public class PunishBrush extends PerformBrush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
final String parameter = par[i].toLowerCase();
if (parameter.equalsIgnoreCase("info"))
{
if (parameter.equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Punish Brush Options:");
v.sendMessage(ChatColor.AQUA + "Punishments can be set via /b p [punishment]");
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 + "Available Punishment Options:");
final StringBuilder punishmentOptions = new StringBuilder();
for (final Punishment punishment : Punishment.values())
{
if (punishmentOptions.length() != 0)
{
for (final Punishment punishment : Punishment.values()) {
if (punishmentOptions.length() != 0) {
punishmentOptions.append(" | ");
}
punishmentOptions.append(punishment.name());
}
v.sendMessage(ChatColor.GOLD + punishmentOptions.toString());
return;
}
else if (parameter.equalsIgnoreCase("-toggleSM"))
{
} else if (parameter.equalsIgnoreCase("-toggleSM")) {
this.specificPlayer = !this.specificPlayer;
if (this.specificPlayer)
{
try
{
if (this.specificPlayer) {
try {
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.");
}
}
}
else if (parameter.equalsIgnoreCase("-toggleSelf"))
{
} else if (parameter.equalsIgnoreCase("-toggleSelf")) {
this.hitsSelf = !this.hitsSelf;
if (hitsSelf)
{
if (hitsSelf) {
v.sendMessage(ChatColor.AQUA + "Your punishments will now affect you too!");
}
else
{
} else {
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;
}
else
{
try
{
} else {
try {
this.punishment = Punishment.valueOf(parameter.toUpperCase());
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.");
}
}
@ -360,11 +310,15 @@ public class PunishBrush extends PerformBrush
}
@Override
public String getPermissionNode() {
return "voxelsniper.brush.punish";
}
/**
* @author Monofraps
*/
private enum Punishment
{
private enum Punishment {
// Monofraps
FIRE, LIGHTNING, BLINDNESS, DRUNK, KILL, RANDOMTP, ALL_POTION,
// Deamon
@ -373,10 +327,4 @@ public class PunishBrush extends PerformBrush
// MikeMatrix
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.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.block.Block;
import java.util.Random;
@ -15,8 +14,7 @@ import java.util.Random;
* @author Piotr
* @author Giltwist (Randomized blockPositionY)
*/
public class RandomErodeBrush extends Brush
{
public class RandomErodeBrush extends Brush {
private final double trueCircle = 0.5;
private BlockWrapper[][][] snap;
private BlockWrapper[][][] firstSnap;
@ -31,85 +29,64 @@ public class RandomErodeBrush extends Brush
/**
*
*/
public RandomErodeBrush()
{
public RandomErodeBrush() {
this.setName("RandomErode");
}
private boolean erode(final int x, final int y, final int z)
{
if (this.snap[x][y][z].isSolid())
{
private boolean erode(final int x, final int y, final int z) {
if (this.snap[x][y][z].isSolid()) {
int d = 0;
if (!this.snap[x + 1][y][z].isSolid())
{
if (!this.snap[x + 1][y][z].isSolid()) {
d++;
}
if (!this.snap[x - 1][y][z].isSolid())
{
if (!this.snap[x - 1][y][z].isSolid()) {
d++;
}
if (!this.snap[x][y + 1][z].isSolid())
{
if (!this.snap[x][y + 1][z].isSolid()) {
d++;
}
if (!this.snap[x][y - 1][z].isSolid())
{
if (!this.snap[x][y - 1][z].isSolid()) {
d++;
}
if (!this.snap[x][y][z + 1].isSolid())
{
if (!this.snap[x][y][z + 1].isSolid()) {
d++;
}
if (!this.snap[x][y][z - 1].isSolid())
{
if (!this.snap[x][y][z - 1].isSolid()) {
d++;
}
return (d >= this.erodeFace);
}
else
{
} else {
return false;
}
}
@SuppressWarnings("deprecation")
private boolean fill(final int x, final int y, final int z)
{
if (this.snap[x][y][z].isSolid())
{
private boolean fill(final int x, final int y, final int z) {
if (this.snap[x][y][z].isSolid()) {
return false;
}
else
{
} else {
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());
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());
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());
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());
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());
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());
d++;
}
@ -117,26 +94,21 @@ public class RandomErodeBrush extends Brush
}
}
private void getMatrix()
{
private void getMatrix() {
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];
int sx = this.getTargetBlock().getX() - (this.bsize + 1);
int sy = this.getTargetBlock().getY() - (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);
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);
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));
sy++;
}
@ -145,23 +117,18 @@ public class RandomErodeBrush extends Brush
sx++;
}
this.firstSnap = this.snap.clone();
}
else
{
} else {
this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize];
int sx = this.getTargetBlock().getX() - (this.bsize + 1);
int sy = this.getTargetBlock().getY() - (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);
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);
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));
sy++;
}
@ -173,32 +140,24 @@ public class RandomErodeBrush extends Brush
}
@SuppressWarnings("deprecation")
private void rerosion(final SnipeData v)
{
private void rerosion(final SnipeData v) {
final Undo undo = new Undo();
if (this.erodeFace >= 0 && this.erodeFace <= 6)
{
for (int currentErodeRecursion = 0; currentErodeRecursion < this.erodeRecursion; currentErodeRecursion++)
{
if (this.erodeFace >= 0 && this.erodeFace <= 6) {
for (int currentErodeRecursion = 0; currentErodeRecursion < this.erodeRecursion; currentErodeRecursion++) {
this.getMatrix();
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);
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);
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 (this.erode(x, y, z))
{
if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= brushSizeSquared)) {
if (this.erode(x, y, z)) {
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);
for (int currentFillRecursion = 0; currentFillRecursion < this.fillRecursion; currentFillRecursion++)
{
for (int currentFillRecursion = 0; currentFillRecursion < this.fillRecursion; currentFillRecursion++) {
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);
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);
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 (this.fill(x, y, z))
{
if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= brushSizeSquared)) {
if (this.fill(x, y, z)) {
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[] firstSnapString : firstSnapSlice)
{
for (final BlockWrapper block : firstSnapString)
{
if (block.getI() != block.getNativeBlock().getTypeId())
{
for (BlockWrapper[][] firstSnapSlice : this.firstSnap) {
for (BlockWrapper[] firstSnapString : firstSnapSlice) {
for (final BlockWrapper block : firstSnapString) {
if (block.getI() != block.getNativeBlock().getTypeId()) {
undo.put(block.getNativeBlock());
}
}
@ -257,30 +205,22 @@ public class RandomErodeBrush extends Brush
}
@SuppressWarnings("deprecation")
private void rfilling(final SnipeData v)
{
private void rfilling(final SnipeData v) {
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);
for (int currentFillRecursion = 0; currentFillRecursion < this.fillRecursion; currentFillRecursion++)
{
for (int currentFillRecursion = 0; currentFillRecursion < this.fillRecursion; currentFillRecursion++) {
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);
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);
for (int y = 1; y < this.snap.length - 1; y++)
{
if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= bSquared))
{
if (this.fill(x, y, z))
{
for (int y = 1; y < this.snap.length - 1; y++) {
if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= bSquared)) {
if (this.fill(x, y, z)) {
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);
for (int currentErodeRecursion = 0; currentErodeRecursion < this.erodeRecursion; currentErodeRecursion++)
{
for (int currentErodeRecursion = 0; currentErodeRecursion < this.erodeRecursion; currentErodeRecursion++) {
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);
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);
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 (this.erode(x, y, z))
{
if (((xSquared + Math.pow(y - (this.bsize + 1), 2) + zSquared) <= bSquared)) {
if (this.erode(x, y, z)) {
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[] firstSnapString : firstSnapSlice)
{
for (final BlockWrapper block : firstSnapString)
{
if (block.getI() != block.getNativeBlock().getTypeId())
{
for (BlockWrapper[][] firstSnapSlice : this.firstSnap) {
for (BlockWrapper[] firstSnapString : firstSnapSlice) {
for (final BlockWrapper block : firstSnapString) {
if (block.getI() != block.getNativeBlock().getTypeId()) {
undo.put(block.getNativeBlock());
}
}
@ -339,8 +268,7 @@ public class RandomErodeBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.bsize = v.getBrushSize();
this.snap = new BlockWrapper[0][0][0];
@ -350,8 +278,7 @@ public class RandomErodeBrush extends Brush
this.erodeRecursion = this.generator.nextInt(3);
this.fillRecursion = this.generator.nextInt(3);
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 (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
// chance to be zero though, for more interestingness -Gav
this.erodeRecursion = this.generator.nextInt(2) + 1;
this.fillRecursion = this.generator.nextInt(2) + 1;
@ -361,8 +288,7 @@ public class RandomErodeBrush extends Brush
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.bsize = v.getBrushSize();
this.snap = new BlockWrapper[0][0][0];
@ -371,8 +297,7 @@ public class RandomErodeBrush extends Brush
this.fillFace = this.generator.nextInt(5) + 1;
this.erodeRecursion = this.generator.nextInt(3);
this.fillRecursion = this.generator.nextInt(3);
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 (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
// chance to be zero though, for more interestingness -Gav
this.erodeRecursion = this.generator.nextInt(2) + 1;
this.fillRecursion = this.generator.nextInt(2) + 1;
@ -382,17 +307,20 @@ public class RandomErodeBrush extends Brush
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
}
@Override
public String getPermissionNode() {
return "voxelsniper.brush.randomerode";
}
/**
* @author unknown
*/
private class BlockWrapper
{
private class BlockWrapper {
private boolean solid;
private AsyncBlock nativeBlock;
private int id;
@ -402,12 +330,10 @@ public class RandomErodeBrush extends Brush
* @param bl
*/
@SuppressWarnings("deprecation")
public BlockWrapper(final AsyncBlock bl)
{
public BlockWrapper(final AsyncBlock bl) {
this.setNativeBlock(bl);
this.setI(bl.getTypeId());
switch (bl.getType())
{
switch (bl.getType()) {
case AIR:
this.setSolid(false);
break;
@ -422,50 +348,36 @@ public class RandomErodeBrush extends Brush
}
}
public boolean isSolid()
{
public boolean isSolid() {
return solid;
}
public void setSolid(boolean solid)
{
public void setSolid(boolean solid) {
this.solid = solid;
}
public AsyncBlock getNativeBlock()
{
public AsyncBlock getNativeBlock() {
return nativeBlock;
}
public void setNativeBlock(AsyncBlock nativeBlock)
{
public void setNativeBlock(AsyncBlock nativeBlock) {
this.nativeBlock = nativeBlock;
}
public int getId()
{
public int getId() {
return id;
}
public void setId(int id)
{
public void setId(int id) {
this.id = id;
}
public int getI()
{
public int getI() {
return i;
}
public void setI(int i)
{
public void setI(int i) {
this.i = i;
}
}
@Override
public String getPermissionNode()
{
return "voxelsniper.brush.randomerode";
}
}

Datei anzeigen

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

Datei anzeigen

@ -5,40 +5,33 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
/**
* http://www.voxelwiki.com/minecraft/Voxelsniper#Ring_Brush
*
* @author Voxel
*/
public class RingBrush extends PerformBrush
{
public class RingBrush extends PerformBrush {
private double trueCircle = 0;
private double innerSize = 0;
/**
*
*/
public RingBrush()
{
public RingBrush() {
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 double outerSquared = Math.pow(brushSize + this.trueCircle, 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);
for (int z = brushSize; z >= 0; z--)
{
for (int z = brushSize; z >= 0; z--) {
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));
@ -51,70 +44,52 @@ public class RingBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.ring(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.ring(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
vm.custom(ChatColor.AQUA + "The inner radius is " + ChatColor.RED + this.innerSize);
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
if (par[i].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) {
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 ir2.5 -- will set the inner radius to 2.5 units");
return;
}
else if (par[i].startsWith("true"))
{
} else if (par[i].startsWith("true")) {
this.trueCircle = 0.5;
v.sendMessage(ChatColor.AQUA + "True circle mode ON.");
}
else if (par[i].startsWith("false"))
{
} else if (par[i].startsWith("false")) {
this.trueCircle = 0;
v.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
}
else if (par[i].startsWith("ir"))
{
try
{
} else if (par[i].startsWith("ir")) {
try {
final double d = Double.parseDouble(par[i].replace("ir", ""));
this.innerSize = d;
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.");
}
}
else
{
} else {
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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.SnipeData;
import com.thevoxelbox.voxelsniper.util.BlockWrapper;
import org.bukkit.ChatColor;
/**
* @author Piotr
*/
public class Rot2DBrush extends Brush
{
public class Rot2DBrush extends Brush {
private int mode = 0;
private int bSize;
private int brushSize;
@ -22,14 +20,12 @@ public class Rot2DBrush extends Brush
/**
*
*/
public Rot2DBrush()
{
public Rot2DBrush() {
this.setName("2D Rotation");
}
@SuppressWarnings("deprecation")
private void getMatrix()
{
private void getMatrix() {
this.brushSize = (this.bSize * 2) + 1;
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 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;
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;
if (xSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared)
{
for (int z = 0; z < this.snap.length; z++)
{
if (xSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) {
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?
this.snap[x][z][y] = new BlockWrapper(block);
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 cos = Math.cos(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
// 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 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;
if (xSquared + Math.pow(zz, 2) <= brushSiyeSquared)
{
if (xSquared + Math.pow(zz, 2) <= brushSiyeSquared) {
final double newX = (xx * cos) - (zz * sin);
final double newZ = (xx * sin) + (zz * cos);
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 BlockWrapper block = this.snap[x][currentY][y];
if (BlockTypes.get(block.getId()).getMaterial().isAir())
{
if (BlockTypes.get(block.getId()).getMaterial().isAir()) {
continue;
}
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 int fx = x + this.getTargetBlock().getX() - this.bSize;
for (int z = 0; z < this.snap.length; z++)
{
if (xSquared + Math.pow(z - this.bSize, 2) <= brushSiyeSquared)
{
for (int z = 0; z < this.snap.length; z++) {
if (xSquared + Math.pow(z - this.bSize, 2) <= brushSiyeSquared) {
final int fz = z + this.getTargetBlock().getZ() - this.bSize;
if (!doNotFill[x][z])
{
if (!doNotFill[x][z]) {
// 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 a = this.getBlockIdAt(fx + 1, fy, fz);
@ -132,20 +113,15 @@ public class Rot2DBrush extends Brush
int winner;
int winnerData;
if (a == b || a == c || a == d)
{ // I figure that since we are already narrowing it down to ONLY the holes left behind, it
if (a == b || a == c || a == d) { // I figure that since we are already narrowing it down to ONLY the holes left behind, it
// should
// be fine to do all 5 checks needed to be legit about it.
winner = a;
winnerData = aData;
}
else if (b == d || c == d)
{
} else if (b == d || c == d) {
winner = d;
winnerData = dData;
}
else
{
} else {
winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C;
winnerData = bData;
}
@ -159,8 +135,7 @@ public class Rot2DBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.bSize = v.getBrushSize();
if (this.mode == 0) {
@ -172,8 +147,7 @@ public class Rot2DBrush extends Brush
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.bSize = v.getBrushSize();
if (this.mode == 0) {
@ -185,21 +159,18 @@ public class Rot2DBrush extends Brush
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
}
@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]));
v.sendMessage(ChatColor.GREEN + "Angle set to " + this.se);
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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.SnipeData;
import com.thevoxelbox.voxelsniper.util.BlockWrapper;
import org.bukkit.Bukkit;
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
// 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 bSize;
private int brushSize;
@ -25,14 +23,12 @@ public class Rot2DvertBrush extends Brush
/**
*
*/
public Rot2DvertBrush()
{
public Rot2DvertBrush() {
this.setName("2D Rotation");
}
@SuppressWarnings("deprecation")
private void getMatrix()
{
private void getMatrix() {
this.brushSize = (this.bSize * 2) + 1;
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 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;
for (int z = 0; z < this.snap.length; z++)
{
for (int z = 0; z < this.snap.length; z++) {
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?
this.snap[x][y][z] = new BlockWrapper(block);
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 cos = Math.cos(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
// 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 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;
if (xSquared + Math.pow(zz, 2) <= brushSizeSquared)
{
if (xSquared + Math.pow(zz, 2) <= brushSizeSquared) {
final double newX = (xx * cos) - (zz * sin);
final double newZ = (xx * sin) + (zz * cos);
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 BlockWrapper block = this.snap[y][x][z];
if (BlockTypes.get(block.getId()).getMaterial().isAir())
{
if (BlockTypes.get(block.getId()).getMaterial().isAir()) {
continue;
}
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 int fx = x + this.getTargetBlock().getX() - this.bSize;
for (int z = 0; z < this.snap.length; z++)
{
if (xSquared + Math.pow(z - this.bSize, 2) <= brushSizeSquared)
{
for (int z = 0; z < this.snap.length; z++) {
if (xSquared + Math.pow(z - this.bSize, 2) <= brushSizeSquared) {
final int fz = z + this.getTargetBlock().getZ() - this.bSize;
if (!doNotFill[x][z])
{
if (!doNotFill[x][z]) {
// 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 a = this.getBlockIdAt(fy, fx + 1, fz);
@ -133,20 +115,15 @@ public class Rot2DvertBrush extends Brush
int winner;
int winnerData;
if (a == b || a == c || a == d)
{ // I figure that since we are already narrowing it down to ONLY the holes left behind, it
if (a == b || a == c || a == d) { // I figure that since we are already narrowing it down to ONLY the holes left behind, it
// should
// be fine to do all 5 checks needed to be legit about it.
winner = a;
winnerData = aData;
}
else if (b == d || c == d)
{
} else if (b == d || c == d) {
winner = d;
winnerData = dData;
}
else
{
} else {
winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C;
winnerData = bData;
}
@ -160,8 +137,7 @@ public class Rot2DvertBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.bSize = v.getBrushSize();
if (this.mode == 0) {
@ -173,8 +149,7 @@ public class Rot2DvertBrush extends Brush
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.bSize = v.getBrushSize();
if (this.mode == 0) {
@ -186,29 +161,23 @@ public class Rot2DvertBrush extends Brush
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
try
{
public final void parameters(final String[] par, final SnipeData v) {
try {
this.se = Math.toRadians(Double.parseDouble(par[1]));
v.sendMessage(ChatColor.GREEN + "Angle set to " + this.se);
}
catch (Exception _ex)
{
} catch (Exception _ex) {
v.sendMessage("Exception while parsing parameter: " + par[1]);
Bukkit.getLogger().severe(_ex.getMessage());
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.rot2dvert";
}
}

Datei anzeigen

@ -6,14 +6,12 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import com.thevoxelbox.voxelsniper.util.BlockWrapper;
import org.bukkit.ChatColor;
/**
*
*/
public class Rot3DBrush extends Brush
{
public class Rot3DBrush extends Brush {
private final int mode = 0;
private int bSize;
private int brushSize;
@ -25,14 +23,12 @@ public class Rot3DBrush extends Brush
/**
*
*/
public Rot3DBrush()
{
public Rot3DBrush() {
this.setName("3D Rotation");
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
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 ) )
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
final String parameter = par[i];
// 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.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.LIGHT_PURPLE + "y[0-359] -- set degrees of yaw rotation (Rotation about the Y axis).");
return;
}
else if (parameter.startsWith("p"))
{
} else if (parameter.startsWith("p")) {
this.sePitch = Math.toRadians(Double.parseDouble(parameter.replace("p", "")));
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");
}
}
else if (parameter.startsWith("r"))
{
} else if (parameter.startsWith("r")) {
this.seRoll = Math.toRadians(Double.parseDouble(parameter.replace("r", "")));
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");
}
}
else if (parameter.startsWith("y"))
{
} else if (parameter.startsWith("y")) {
this.seYaw = Math.toRadians(Double.parseDouble(parameter.replace("y", "")));
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");
}
}
@ -88,8 +72,7 @@ public class Rot3DBrush extends Brush
}
@SuppressWarnings("deprecation")
private void getMatrix()
{ // only need to do once. But y needs to change + sphere
private void getMatrix() { // only need to do once. But y needs to change + sphere
final double brushSizeSquared = Math.pow(this.bSize + 0.5, 2);
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 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);
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);
sz = this.getTargetBlock().getY() - this.bSize;
for (int y = 0; y < this.snap.length; y++)
{
if (xSquared + zSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared)
{
for (int y = 0; y < this.snap.length; y++) {
if (xSquared + zSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) {
final AsyncBlock block = this.clampY(sx, sz, sz);
this.snap[x][y][z] = new BlockWrapper(block);
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
// 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
@ -147,23 +125,19 @@ public class Rot3DBrush extends Brush
final boolean[][][] doNotFill = new boolean[this.snap.length][this.snap.length][this.snap.length];
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 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 double zSquared = Math.pow(zz, 2);
final double newxzX = (xx * cosYaw) - (zz * sinYaw);
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;
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
// 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.
final BlockWrapper block = this.snap[x][y][z];
if (BlockTypes.get(block.getId()).getMaterial().isAir())
{
if (BlockTypes.get(block.getId()).getMaterial().isAir()) {
continue;
}
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 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 int fz = z + this.getTargetBlock().getZ() - this.bSize;
for (int y = 0; y < this.snap.length; y++)
{
if (xSquared + zSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared)
{
if (!doNotFill[x][y][z])
{
for (int y = 0; y < this.snap.length; y++) {
if (xSquared + zSquared + Math.pow(y - this.bSize, 2) <= brushSizeSquared) {
if (!doNotFill[x][y][z]) {
// smart fill stuff
final int fy = y + this.getTargetBlock().getY() - this.bSize;
final int a = this.getBlockIdAt(fx + 1, fy, fz);
@ -216,20 +184,15 @@ public class Rot3DBrush extends Brush
int winner;
int winnerData;
if (a == b || a == c || a == d)
{ // I figure that since we are already narrowing it down to ONLY the holes left behind, it
if (a == b || a == c || a == d) { // I figure that since we are already narrowing it down to ONLY the holes left behind, it
// should
// be fine to do all 5 checks needed to be legit about it.
winner = a;
winnerData = aData;
}
else if (b == d || c == d)
{
} else if (b == d || c == d) {
winner = d;
winnerData = dData;
}
else
{
} else {
winner = b; // blockPositionY making this default, it will also automatically cover situations where B = C;
winnerData = bData;
}
@ -244,8 +207,7 @@ public class Rot3DBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.bSize = v.getBrushSize();
if (this.mode == 0) {
@ -257,8 +219,7 @@ public class Rot3DBrush extends Brush
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.bSize = v.getBrushSize();
if (this.mode == 0) {
@ -270,8 +231,7 @@ public class Rot3DBrush extends Brush
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.rot3d";
}
}

Datei anzeigen

@ -3,7 +3,6 @@ package com.thevoxelbox.voxelsniper.brush;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.util.Vector;
@ -12,8 +11,7 @@ import org.bukkit.util.Vector;
*
* @author Gavjenks
*/
public class RulerBrush extends Brush
{
public class RulerBrush extends Brush {
private boolean first = true;
private Vector coords = new Vector(0, 0, 0);
@ -24,24 +22,19 @@ public class RulerBrush extends Brush
/**
*
*/
public RulerBrush()
{
public RulerBrush() {
this.setName("Ruler");
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
final int voxelMaterialId = v.getVoxelId();
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.");
this.first = !this.first;
}
else
{
} else {
final Undo undo = new Undo();
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
protected final void powder(final SnipeData v)
{
if (this.coords == null || this.coords.lengthSquared() == 0)
{
protected final void powder(final SnipeData v) {
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.");
return;
}
@ -71,59 +62,44 @@ public class RulerBrush extends Brush
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.voxel();
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; 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.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.");
return;
}
else if (parameter.startsWith("x"))
{
} else if (parameter.startsWith("x")) {
this.xOff = Integer.parseInt(parameter.replace("x", ""));
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", ""));
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", ""));
v.sendMessage(ChatColor.AQUA + "Z offset set to " + this.zOff);
}
else if (parameter.startsWith("ruler"))
{
} else if (parameter.startsWith("ruler")) {
this.zOff = 0;
this.yOff = 0;
this.xOff = 0;
v.sendMessage(ChatColor.BLUE + "Ruler mode.");
}
else
{
} else {
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
@ -12,8 +11,7 @@ import org.bukkit.block.BlockFace;
/**
* @author DivineRage
*/
public class ScannerBrush extends Brush
{
public class ScannerBrush extends Brush {
private static final int DEPTH_MIN = 1;
private static final int DEPTH_DEFAULT = 24;
private static final int DEPTH_MAX = 64;
@ -24,42 +22,30 @@ public class ScannerBrush extends Brush
/**
*
*/
public ScannerBrush()
{
public ScannerBrush() {
this.setName("Scanner");
}
private int clamp(final int value, final int min, final int max)
{
if (value < min)
{
private int clamp(final int value, final int min, final int max) {
if (value < min) {
return min;
}
else if (value > max)
{
} else if (value > max) {
return max;
}
else
{
} else {
return value;
}
}
private void scan(final SnipeData v, final BlockFace bf)
{
if (bf == null)
{
private void scan(final SnipeData v, final BlockFace bf) {
if (bf == null) {
return;
}
switch (bf)
{
switch (bf) {
case NORTH:
// Scan south
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)
{
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) {
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
return;
}
@ -69,10 +55,8 @@ public class ScannerBrush extends Brush
case SOUTH:
// Scan north
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)
{
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) {
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
return;
}
@ -82,10 +66,8 @@ public class ScannerBrush extends Brush
case EAST:
// Scan west
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)
{
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) {
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
return;
}
@ -95,10 +77,8 @@ public class ScannerBrush extends Brush
case WEST:
// Scan east
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)
{
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) {
v.sendMessage(ChatColor.GREEN + "" + this.checkFor + " found after " + i + " blocks.");
return;
}
@ -108,14 +88,11 @@ public class ScannerBrush extends Brush
case UP:
// Scan down
for (int i = 1; i < this.depth + 1; i++)
{
if ((this.getTargetBlock().getY() - i) <= 0)
{
for (int i = 1; i < this.depth + 1; i++) {
if ((this.getTargetBlock().getY() - i) <= 0) {
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.");
return;
}
@ -125,14 +102,11 @@ public class ScannerBrush extends Brush
case DOWN:
// Scan up
for (int i = 1; i < this.depth + 1; i++)
{
if ((this.getTargetBlock().getY() + i) >= v.getWorld().getMaxHeight())
{
for (int i = 1; i < this.depth + 1; i++) {
if ((this.getTargetBlock().getY() + i) >= v.getWorld().getMaxHeight()) {
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.");
return;
}
@ -146,55 +120,45 @@ public class ScannerBrush extends Brush
}
@SuppressWarnings("deprecation")
@Override
protected final void arrow(final SnipeData v)
{
@Override
protected final void arrow(final SnipeData v) {
this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId()));
this.scan(v, this.getTargetBlock().getFace(this.getLastBlock()));
}
@SuppressWarnings("deprecation")
@Override
protected final void powder(final SnipeData v)
{
@Override
protected final void powder(final SnipeData v) {
this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId()));
this.scan(v, this.getTargetBlock().getFace(this.getLastBlock()));
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.custom(ChatColor.GREEN + "Scanner depth set to " + this.depth);
vm.custom(ChatColor.GREEN + "Scanner scans for " + this.checkFor + " (change with /v #)");
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
if (par[i].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Scanner brush Parameters:");
v.sendMessage(ChatColor.AQUA + "/b sc d# -- will set the search depth to #. Clamps to 1 - 64.");
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);
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.scanner";
}
}

Datei anzeigen

@ -11,30 +11,23 @@ import org.bukkit.block.Block;
*
* @author Voxel
*/
public class SetBrush extends PerformBrush
{
public class SetBrush extends PerformBrush {
private static final int SELECTION_SIZE_MAX = 5000000;
private Block block = null;
/**
*
*/
public SetBrush()
{
public SetBrush() {
this.setName("Set");
}
private boolean set(final Block bl, final SnipeData v)
{
if (this.block == null)
{
private boolean set(final Block bl, final SnipeData v) {
if (this.block == null) {
this.block = bl;
return true;
}
else
{
if (!this.block.getWorld().getName().equals(bl.getWorld().getName()))
{
} else {
if (!this.block.getWorld().getName().equals(bl.getWorld().getName())) {
v.sendMessage(ChatColor.RED + "You selected points in different worlds!");
this.block = null;
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 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.");
}
else
{
for (int y = lowY; y <= highY; y++)
{
for (int x = lowX; x <= highX; x++)
{
for (int z = lowZ; z <= highZ; z++)
{
} else {
for (int y = lowY; y <= highY; y++) {
for (int x = lowX; x <= highX; x++) {
for (int z = lowZ; z <= highZ; z++) {
this.current.perform(this.clampY(x, y, z));
}
}
@ -70,47 +57,36 @@ public class SetBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
if (this.set(this.getTargetBlock(), v))
{
protected final void arrow(final SnipeData v) {
if (this.set(this.getTargetBlock(), v)) {
v.sendMessage(ChatColor.GRAY + "Point one");
}
else
{
} else {
v.owner().storeUndo(this.current.getUndo());
}
}
@Override
protected final void powder(final SnipeData v)
{
if (this.set(this.getLastBlock(), v))
{
protected final void powder(final SnipeData v) {
if (this.set(this.getLastBlock(), v)) {
v.sendMessage(ChatColor.GRAY + "Point one");
}
else
{
} else {
v.owner().storeUndo(this.current.getUndo());
}
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
this.block = null;
vm.brushName(this.getName());
}
@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);
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.set";
}
}

Datei anzeigen

@ -11,8 +11,7 @@ import org.bukkit.block.Block;
/**
* @author Voxel
*/
public class SetRedstoneFlipBrush extends Brush
{
public class SetRedstoneFlipBrush extends Brush {
private Block block = null;
private Undo undo;
private boolean northSouth = true;
@ -20,20 +19,15 @@ public class SetRedstoneFlipBrush extends Brush
/**
*
*/
public SetRedstoneFlipBrush()
{
public SetRedstoneFlipBrush() {
this.setName("Set Redstone Flip");
}
private boolean set(final Block bl)
{
if (this.block == null)
{
private boolean set(final Block bl) {
if (this.block == null) {
this.block = bl;
return true;
}
else
{
} else {
this.undo = new Undo();
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();
@ -42,12 +36,9 @@ public class SetRedstoneFlipBrush extends Brush
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();
for (int y = lowY; y <= highY; y++)
{
for (int x = lowX; x <= highX; x++)
{
for (int z = lowZ; z <= highZ; z++)
{
for (int y = lowY; y <= highY; y++) {
for (int x = lowX; x <= highX; x++) {
for (int z = lowZ; z <= highZ; z++) {
this.perform(this.clampY(x, y, z));
}
}
@ -58,32 +49,21 @@ public class SetRedstoneFlipBrush extends Brush
}
@SuppressWarnings("deprecation")
private void perform(final AsyncBlock bl)
{
if (bl.getType() == Material.REPEATER)
{
if (this.northSouth)
{
if ((bl.getPropertyId() % 4) == 1)
{
private void perform(final AsyncBlock bl) {
if (bl.getType() == Material.REPEATER) {
if (this.northSouth) {
if ((bl.getPropertyId() % 4) == 1) {
this.undo.put(bl);
bl.setPropertyId((bl.getPropertyId() + 2));
}
else if ((bl.getPropertyId() % 4) == 3)
{
} else if ((bl.getPropertyId() % 4) == 3) {
this.undo.put(bl);
bl.setPropertyId((bl.getPropertyId() - 2));
}
}
else
{
if ((bl.getPropertyId() % 4) == 2)
{
} else {
if ((bl.getPropertyId() % 4) == 2) {
this.undo.put(bl);
bl.setPropertyId((bl.getPropertyId() - 2));
}
else if ((bl.getPropertyId() % 4) == 0)
{
} else if ((bl.getPropertyId() % 4) == 0) {
this.undo.put(bl);
bl.setPropertyId((bl.getPropertyId() + 2));
}
@ -92,69 +72,51 @@ public class SetRedstoneFlipBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
if (this.set(this.getTargetBlock()))
{
protected final void arrow(final SnipeData v) {
if (this.set(this.getTargetBlock())) {
v.sendMessage(ChatColor.GRAY + "Point one");
}
else
{
} else {
v.owner().storeUndo(this.undo);
}
}
@Override
protected final void powder(final SnipeData v)
{
if (this.set(this.getLastBlock()))
{
protected final void powder(final SnipeData v) {
if (this.set(this.getLastBlock())) {
v.sendMessage(ChatColor.GRAY + "Point one");
}
else
{
} else {
v.owner().storeUndo(this.undo);
}
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
this.block = null;
vm.brushName(this.getName());
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
if (par[i].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) {
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.");
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;
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;
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.setredstoneflip";
}
}

Datei anzeigen

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

Datei anzeigen

@ -12,19 +12,16 @@ import org.bukkit.block.Block;
*
* @author Voxel
*/
public class ShellBallBrush extends Brush
{
public class ShellBallBrush extends Brush {
/**
*
*/
public ShellBallBrush()
{
public ShellBallBrush() {
this.setName("Shell Ball");
}
// 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 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
@ -34,65 +31,50 @@ public class ShellBallBrush extends Brush
int blockPositionY = targetBlock.getY();
int blockPositionZ = targetBlock.getZ();
// Log current materials into oldmats
for (int x = 0; x <= 2 * (brushSize + 1); x++)
{
for (int y = 0; y <= 2 * (brushSize + 1); y++)
{
for (int z = 0; z <= 2 * (brushSize + 1); z++)
{
for (int x = 0; x <= 2 * (brushSize + 1); x++) {
for (int y = 0; y <= 2 * (brushSize + 1); y++) {
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);
}
}
}
// Log current materials into newmats
for (int x = 0; x <= brushSizeDoubled; x++)
{
for (int y = 0; y <= brushSizeDoubled; y++)
{
for (int x = 0; x <= brushSizeDoubled; x++) {
for (int y = 0; y <= brushSizeDoubled; y++) {
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
brushSizeDoubled + 1);
brushSizeDoubled + 1);
}
}
int temp;
// Hollow Brush Area
for (int x = 0; x <= brushSizeDoubled; x++)
{
for (int y = 0; y <= brushSizeDoubled; y++)
{
for (int z = 0; z <= brushSizeDoubled; z++)
{
for (int x = 0; x <= brushSizeDoubled; x++) {
for (int y = 0; y <= brushSizeDoubled; y++) {
for (int z = 0; z <= brushSizeDoubled; z++) {
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++;
}
if (oldMaterials[x + 1 - 1][y + 1][z + 1] == v.getReplaceId())
{
if (oldMaterials[x + 1 - 1][y + 1][z + 1] == v.getReplaceId()) {
temp++;
}
if (oldMaterials[x + 1][y + 1 + 1][z + 1] == v.getReplaceId())
{
if (oldMaterials[x + 1][y + 1 + 1][z + 1] == v.getReplaceId()) {
temp++;
}
if (oldMaterials[x + 1][y + 1 - 1][z + 1] == v.getReplaceId())
{
if (oldMaterials[x + 1][y + 1 - 1][z + 1] == v.getReplaceId()) {
temp++;
}
if (oldMaterials[x + 1][y + 1][z + 1 + 1] == v.getReplaceId())
{
if (oldMaterials[x + 1][y + 1][z + 1 + 1] == v.getReplaceId()) {
temp++;
}
if (oldMaterials[x + 1][y + 1][z + 1 - 1] == v.getReplaceId())
{
if (oldMaterials[x + 1][y + 1][z + 1 - 1] == v.getReplaceId()) {
temp++;
}
if (temp == 0)
{
if (temp == 0) {
newMaterials[x][y][z] = v.getVoxelId();
}
}
@ -103,20 +85,15 @@ public class ShellBallBrush extends Brush
final Undo undo = new Undo();
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);
for (int y = 0; y <= 2 * brushSize; y++)
{
for (int y = 0; y <= 2 * brushSize; y++) {
final double ySquared = Math.pow(y - brushSize, 2);
for (int z = 2 * brushSize; z >= 0; z--)
{
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])
{
for (int z = 2 * brushSize; z >= 0; z--) {
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]) {
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]);
@ -131,20 +108,17 @@ public class ShellBallBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.bShell(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.bShell(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
vm.voxel();
@ -152,8 +126,7 @@ public class ShellBallBrush extends Brush
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.shellball";
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -7,12 +7,7 @@ import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
/**
* Overwrites signs. (Wiki:
@ -20,8 +15,7 @@ import java.io.IOException;
*
* @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 NUM_SIGN_LINES = 4;
// these are no array indices
@ -36,8 +30,7 @@ public class SignOverwriteBrush extends Brush
/**
*
*/
public SignOverwriteBrush()
{
public SignOverwriteBrush() {
this.setName("Sign Overwrite Brush");
clearBuffer();
@ -49,12 +42,9 @@ public class SignOverwriteBrush extends Brush
*
* @param sign
*/
private void setSignText(final Sign sign)
{
for (int i = 0; i < this.signTextLines.length; i++)
{
if (this.signLinesEnabled[i])
{
private void setSignText(final Sign sign) {
for (int i = 0; i < this.signTextLines.length; i++) {
if (this.signLinesEnabled[i]) {
sign.setLine(i, this.signTextLines[i]);
}
}
@ -67,14 +57,10 @@ public class SignOverwriteBrush extends Brush
*
* @param v
*/
private void setSingle(final SnipeData v)
{
if (this.getTargetBlock().getState() instanceof Sign)
{
private void setSingle(final SnipeData v) {
if (this.getTargetBlock().getState() instanceof Sign) {
setSignText((Sign) this.getTargetBlock().getState());
}
else
{
} else {
v.sendMessage(ChatColor.RED + "Target block is not a sign.");
return;
}
@ -85,8 +71,7 @@ public class SignOverwriteBrush extends Brush
*
* @param v
*/
private void setRanged(final SnipeData v)
{
private void setRanged(final SnipeData v) {
final int minX = getTargetBlock().getX() - v.getBrushSize();
final int maxX = getTargetBlock().getX() + v.getBrushSize();
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
for (int x = minX; x <= maxX; x++)
{
for (int y = minY; y <= maxY; y++)
{
for (int z = minZ; z <= maxZ; z++)
{
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
BlockState blockState = this.getWorld().getBlockAt(x, y, z).getState();
if (blockState instanceof Sign)
{
if (blockState instanceof Sign) {
setSignText((Sign) blockState);
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.");
}
}
@Override
protected final void arrow(final SnipeData v)
{
if (this.rangedMode)
{
protected final void arrow(final SnipeData v) {
if (this.rangedMode) {
setRanged(v);
}
else
{
} else {
setSingle(v);
}
}
@Override
protected final void powder(final SnipeData v)
{
if (this.getTargetBlock().getState() instanceof Sign)
{
protected final void powder(final SnipeData v) {
if (this.getTargetBlock().getState() instanceof Sign) {
Sign sign = (Sign) this.getTargetBlock().getState();
for (int i = 0; i < this.signTextLines.length; i++)
{
if (this.signLinesEnabled[i])
{
for (int i = 0; i < this.signTextLines.length; i++) {
if (this.signLinesEnabled[i]) {
this.signTextLines[i] = sign.getLine(i);
}
}
displayBuffer(v);
}
else
{
} else {
v.sendMessage(ChatColor.RED + "Target block is not a sign.");
}
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
public final void parameters(final String[] par, final SnipeData v) {
boolean textChanged = false;
for (int i = 0; i < par.length; i++)
{
for (int i = 0; i < par.length; i++) {
String parameter = par[i];
try
{
if (parameter.equalsIgnoreCase("info"))
{
try {
if (parameter.equalsIgnoreCase("info")) {
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 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 + "-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)");
}
else if (parameter.startsWith("-1"))
{
} else if (parameter.startsWith("-1")) {
textChanged = true;
i = parseSignLineFromParam(par, SIGN_LINE_1, v, i);
}
else if (parameter.startsWith("-2"))
{
} else if (parameter.startsWith("-2")) {
textChanged = true;
i = parseSignLineFromParam(par, SIGN_LINE_2, v, i);
}
else if (parameter.startsWith("-3"))
{
} else if (parameter.startsWith("-3")) {
textChanged = true;
i = parseSignLineFromParam(par, SIGN_LINE_3, v, i);
}
else if (parameter.startsWith("-4"))
{
} else if (parameter.startsWith("-4")) {
textChanged = true;
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();
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();
resetStates();
v.sendMessage(ChatColor.BLUE + "Internal text buffer cleard and states back to enabled.");
}
else if (parameter.equalsIgnoreCase("-multiple") || parameter.equalsIgnoreCase("-m"))
{
if ((i + 1) >= par.length)
{
} else if (parameter.equalsIgnoreCase("-multiple") || parameter.equalsIgnoreCase("-m")) {
if ((i + 1) >= par.length) {
v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter));
continue;
}
rangedMode = (par[++i].equalsIgnoreCase("on") || par[++i].equalsIgnoreCase("yes"));
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.AQUA + "Brush height set to " + ChatColor.RED + v.getVoxelHeight());
}
}
else if (parameter.equalsIgnoreCase("-save") || parameter.equalsIgnoreCase("-s"))
{
if ((i + 1) >= par.length)
{
} else if (parameter.equalsIgnoreCase("-save") || parameter.equalsIgnoreCase("-s")) {
if ((i + 1) >= par.length) {
v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter));
continue;
}
String fileName = par[++i];
saveBufferToFile(fileName, v);
}
else if (parameter.equalsIgnoreCase("-open") || parameter.equalsIgnoreCase("-o"))
{
if ((i + 1) >= par.length)
{
} else if (parameter.equalsIgnoreCase("-open") || parameter.equalsIgnoreCase("-o")) {
if ((i + 1) >= par.length) {
v.sendMessage(ChatColor.RED + String.format("Missing parameter after %s.", parameter));
continue;
}
@ -251,16 +195,13 @@ public class SignOverwriteBrush extends Brush
loadBufferFromFile(fileName, "", v);
textChanged = true;
}
}
catch (Exception exception)
{
} catch (Exception exception) {
v.sendMessage(ChatColor.RED + String.format("Error while parsing parameter %s", parameter));
exception.printStackTrace();
}
}
if (textChanged)
{
if (textChanged) {
displayBuffer(v);
}
}
@ -276,25 +217,21 @@ public class SignOverwriteBrush extends Brush
* @param i
* @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 String parameter = params[i];
boolean statusSet = false;
if (parameter.contains(":"))
{
if (parameter.contains(":")) {
this.signLinesEnabled[lineIndex] = parameter.substring(parameter.indexOf(":")).equalsIgnoreCase(":enabled");
v.sendMessage(ChatColor.BLUE + "Line " + lineNumber + " is " + ChatColor.GREEN + (this.signLinesEnabled[lineIndex] ? "enabled" : "disabled"));
statusSet = true;
}
if ((i + 1) >= params.length)
{
if ((i + 1) >= params.length) {
// return if the user just wanted to set the status
if (statusSet)
{
if (statusSet) {
return i;
}
@ -306,17 +243,13 @@ public class SignOverwriteBrush extends Brush
String newText = "";
// 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];
if (currentParameter.startsWith("-"))
{
if (currentParameter.startsWith("-")) {
i--;
break;
}
else
{
} else {
newText += currentParameter + " ";
}
}
@ -324,22 +257,17 @@ public class SignOverwriteBrush extends Brush
newText = ChatColor.translateAlternateColorCodes('&', newText);
// 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);
}
else if (newText.isEmpty())
{
if (statusSet)
{
} else if (newText.isEmpty()) {
if (statusSet) {
return i;
}
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
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.");
newText = newText.substring(0, MAX_SIGN_LINE_LENGTH);
}
@ -348,11 +276,9 @@ public class SignOverwriteBrush extends Brush
return i;
}
private void displayBuffer(final SnipeData v)
{
private void displayBuffer(final SnipeData v) {
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]);
}
}
@ -363,24 +289,20 @@ public class SignOverwriteBrush extends Brush
* @param fileName
* @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");
if (store.exists())
{
if (store.exists()) {
v.sendMessage("This file already exists.");
return;
}
try
{
try {
store.createNewFile();
FileWriter outFile = new FileWriter(store);
BufferedWriter outStream = new BufferedWriter(outFile);
for (int i = 0; i < this.signTextLines.length; i++)
{
outStream.write(String.valueOf(this.signLinesEnabled[i]) + "\n");
for (int i = 0; i < this.signTextLines.length; i++) {
outStream.write(this.signLinesEnabled[i] + "\n");
outStream.write(this.signTextLines[i] + "\n");
}
@ -388,9 +310,7 @@ public class SignOverwriteBrush extends Brush
outFile.close();
v.sendMessage(ChatColor.BLUE + "File saved successfully.");
}
catch (IOException exception)
{
} catch (IOException exception) {
v.sendMessage(ChatColor.RED + "Failed to save file. " + exception.getMessage());
exception.printStackTrace();
}
@ -403,22 +323,18 @@ public class SignOverwriteBrush extends Brush
* @param userDomain
* @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");
if (!store.exists())
{
if (!store.exists()) {
v.sendMessage("This file does not exist.");
return;
}
try
{
try {
FileReader inFile = new FileReader(store);
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.signTextLines[i] = inStream.readLine();
}
@ -427,9 +343,7 @@ public class SignOverwriteBrush extends Brush
inFile.close();
v.sendMessage(ChatColor.BLUE + "File loaded successfully.");
}
catch (IOException exception)
{
} catch (IOException exception) {
v.sendMessage(ChatColor.RED + "Failed to load file. " + exception.getMessage());
exception.printStackTrace();
}
@ -438,10 +352,8 @@ public class SignOverwriteBrush extends Brush
/**
* Clears the internal text buffer. (Sets it to empty strings)
*/
private void clearBuffer()
{
for (int i = 0; i < this.signTextLines.length; i++)
{
private void clearBuffer() {
for (int i = 0; i < this.signTextLines.length; i++) {
this.signTextLines[i] = "";
}
}
@ -449,36 +361,30 @@ public class SignOverwriteBrush extends Brush
/**
* Resets line enabled states to enabled.
*/
private void resetStates()
{
for (int i = 0; i < this.signLinesEnabled.length; i++)
{
private void resetStates() {
for (int i = 0; i < this.signLinesEnabled.length; i++) {
this.signLinesEnabled[i] = true;
}
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName("Sign Overwrite Brush");
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(ChatColor.BLUE + String.format("Ranged mode is %s", ChatColor.GREEN + (rangedMode ? "enabled" : "disabled")));
if (rangedMode)
{
if (rangedMode) {
vm.size();
vm.height();
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.signoverwrite";
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -1,15 +1,12 @@
package com.thevoxelbox.voxelsniper.brush;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
/**
@ -17,8 +14,7 @@ import org.bukkit.block.Block;
*
* @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 sdirect = "c"; // "c" clockwise (default), "cc" counter-clockwise
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");
}
@SuppressWarnings("deprecation")
private void buildStairWell(final SnipeData v, Block targetBlock)
{
if (v.getVoxelHeight() < 1)
{
private void buildStairWell(final SnipeData v, Block targetBlock) {
if (v.getVoxelHeight() < 1) {
v.setVoxelHeight(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 toggle = 0;
if (this.sdirect.equalsIgnoreCase("cc"))
{
if (this.sopen.equalsIgnoreCase("n"))
{
if (this.sdirect.equalsIgnoreCase("cc")) {
if (this.sopen.equalsIgnoreCase("n")) {
startX = 0;
startZ = 2 * v.getBrushSize();
}
else if (this.sopen.equalsIgnoreCase("e"))
{
} else if (this.sopen.equalsIgnoreCase("e")) {
startX = 0;
startZ = 0;
}
else if (this.sopen.equalsIgnoreCase("s"))
{
} else if (this.sopen.equalsIgnoreCase("s")) {
startX = 2 * v.getBrushSize();
startZ = 0;
}
else
{
} else {
startX = 2 * v.getBrushSize();
startZ = 2 * v.getBrushSize();
}
}
else
{
if (this.sopen.equalsIgnoreCase("n"))
{
} else {
if (this.sopen.equalsIgnoreCase("n")) {
startX = 0;
startZ = 0;
}
else if (this.sopen.equalsIgnoreCase("e"))
{
} else if (this.sopen.equalsIgnoreCase("e")) {
startX = 2 * v.getBrushSize();
startZ = 0;
}
else if (this.sopen.equalsIgnoreCase("s"))
{
} else if (this.sopen.equalsIgnoreCase("s")) {
startX = 2 * v.getBrushSize();
startZ = 2 * v.getBrushSize();
}
else
{
} else {
startX = 0;
startZ = 2 * v.getBrushSize();
}
}
while (y < v.getVoxelHeight())
{
if (this.stairtype.equalsIgnoreCase("block"))
{
while (y < v.getVoxelHeight()) {
if (this.stairtype.equalsIgnoreCase("block")) {
// 1x1x1 voxel material steps
spiral[startX + xOffset][y][startZ + zOffset] = 1;
y++;
}
else if (this.stairtype.equalsIgnoreCase("step"))
{
} else if (this.stairtype.equalsIgnoreCase("step")) {
// alternating step-doublestep, uses data value to determine type
switch (toggle)
{
switch (toggle) {
case 0:
toggle = 2;
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
if (startX + xOffset == 0)
{ // All North
if (startZ + zOffset == 0)
{ // NORTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
if (startX + xOffset == 0) { // All North
if (startZ + zOffset == 0) { // NORTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 1;
}
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.sdirect.equalsIgnoreCase("c")) {
xOffset++;
}
else
{
} else {
zOffset++;
}
}
else if (startZ + zOffset == 2 * v.getBrushSize())
{ // NORTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else if (startZ + zOffset == 2 * v.getBrushSize()) { // NORTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 1;
}
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.sdirect.equalsIgnoreCase("c")) {
zOffset--;
}
else
{
} else {
xOffset++;
}
}
else
{ // JUST PLAIN NORTH
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else { // JUST PLAIN NORTH
if (this.sdirect.equalsIgnoreCase("c")) {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 5;
y++;
}
zOffset--;
}
else
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 4;
y++;
}
zOffset++;
}
}
}
else if (startX + xOffset == 2 * v.getBrushSize())
{ // ALL SOUTH
if (startZ + zOffset == 0)
{ // SOUTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else if (startX + xOffset == 2 * v.getBrushSize()) { // ALL SOUTH
if (startZ + zOffset == 0) { // SOUTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 1;
}
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.sdirect.equalsIgnoreCase("c")) {
zOffset++;
}
else
{
} else {
xOffset--;
}
}
else if (startZ + zOffset == 2 * v.getBrushSize())
{ // SOUTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else if (startZ + zOffset == 2 * v.getBrushSize()) { // SOUTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 1;
}
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.sdirect.equalsIgnoreCase("c")) {
xOffset--;
}
else
{
} else {
zOffset--;
}
}
else
{ // JUST PLAIN SOUTH
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else { // JUST PLAIN SOUTH
if (this.sdirect.equalsIgnoreCase("c")) {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 4;
y++;
}
zOffset++;
}
else
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 5;
y++;
}
zOffset--;
}
}
}
else if (startZ + zOffset == 0)
{ // JUST PLAIN EAST
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else if (startZ + zOffset == 0) { // JUST PLAIN EAST
if (this.sdirect.equalsIgnoreCase("c")) {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 2;
y++;
}
xOffset++;
}
else
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 3;
y++;
}
xOffset--;
}
}
else
{ // JUST PLAIN WEST
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else { // JUST PLAIN WEST
if (this.sdirect.equalsIgnoreCase("c")) {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 3;
y++;
}
xOffset--;
}
else
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 2;
y++;
}
@ -286,28 +204,20 @@ public class SpiralStaircaseBrush extends Brush
final Undo undo = new Undo();
// Make the changes
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int i = v.getVoxelHeight() - 1; i >= 0; i--)
{
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int i = v.getVoxelHeight() - 1; i >= 0; i--) {
for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
int blockPositionX = targetBlock.getX();
int blockPositionY = targetBlock.getY();
int blockPositionZ = targetBlock.getZ();
switch (spiral[x][i][z])
{
switch (spiral[x][i][z]) {
case 0:
if (i != v.getVoxelHeight() - 1)
{
if (!((this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) && spiral[x][i + 1][z] == 1))
{
if (i != v.getVoxelHeight() - 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());
}
}
else
{
} else {
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) {
}
if (this.stairtype.equalsIgnoreCase("block"))
{
if (this.stairtype.equalsIgnoreCase("block")) {
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());
}
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());
}
break;
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());
}
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, 67, 0);
} 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, 67, 0);
}
break;
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));
}
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));
}
break;
@ -362,10 +259,8 @@ public class SpiralStaircaseBrush extends Brush
}
@SuppressWarnings("deprecation")
private void digStairWell(final SnipeData v, Block targetBlock)
{
if (v.getVoxelHeight() < 1)
{
private void digStairWell(final SnipeData v, Block targetBlock) {
if (v.getVoxelHeight() < 1) {
v.setVoxelHeight(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 toggle = 0;
if (this.sdirect.equalsIgnoreCase("cc"))
{
if (this.sopen.equalsIgnoreCase("n"))
{
if (this.sdirect.equalsIgnoreCase("cc")) {
if (this.sopen.equalsIgnoreCase("n")) {
startX = 0;
startZ = 2 * v.getBrushSize();
}
else if (this.sopen.equalsIgnoreCase("e"))
{
} else if (this.sopen.equalsIgnoreCase("e")) {
startX = 0;
startZ = 0;
}
else if (this.sopen.equalsIgnoreCase("s"))
{
} else if (this.sopen.equalsIgnoreCase("s")) {
startX = 2 * v.getBrushSize();
startZ = 0;
}
else
{
} else {
startX = 2 * v.getBrushSize();
startZ = 2 * v.getBrushSize();
}
}
else
{
if (this.sopen.equalsIgnoreCase("n"))
{
} else {
if (this.sopen.equalsIgnoreCase("n")) {
startX = 0;
startZ = 0;
}
else if (this.sopen.equalsIgnoreCase("e"))
{
} else if (this.sopen.equalsIgnoreCase("e")) {
startX = 2 * v.getBrushSize();
startZ = 0;
}
else if (this.sopen.equalsIgnoreCase("s"))
{
} else if (this.sopen.equalsIgnoreCase("s")) {
startX = 2 * v.getBrushSize();
startZ = 2 * v.getBrushSize();
}
else
{
} else {
startX = 0;
startZ = 2 * v.getBrushSize();
}
}
while (y < v.getVoxelHeight())
{
if (this.stairtype.equalsIgnoreCase("block"))
{
while (y < v.getVoxelHeight()) {
if (this.stairtype.equalsIgnoreCase("block")) {
// 1x1x1 voxel material steps
spiral[startX + xOffset][y][startZ + zOffset] = 1;
y++;
}
else if (this.stairtype.equalsIgnoreCase("step"))
{
} else if (this.stairtype.equalsIgnoreCase("step")) {
// alternating step-doublestep, uses data value to determine type
switch (toggle)
{
switch (toggle) {
case 0:
toggle = 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
if (startX + xOffset == 0)
{ // All North
if (startZ + zOffset == 0)
{ // NORTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
if (startX + xOffset == 0) { // All North
if (startZ + zOffset == 0) { // NORTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 1;
}
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.sdirect.equalsIgnoreCase("c")) {
xOffset++;
}
else
{
} else {
zOffset++;
}
}
else if (startZ + zOffset == 2 * v.getBrushSize())
{ // NORTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else if (startZ + zOffset == 2 * v.getBrushSize()) { // NORTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 1;
}
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.sdirect.equalsIgnoreCase("c")) {
zOffset--;
}
else
{
} else {
xOffset++;
}
}
else
{ // JUST PLAIN NORTH
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else { // JUST PLAIN NORTH
if (this.sdirect.equalsIgnoreCase("c")) {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 4;
y++;
}
zOffset--;
}
else
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 5;
y++;
}
@ -516,54 +370,34 @@ public class SpiralStaircaseBrush extends Brush
}
}
}
else if (startX + xOffset == 2 * v.getBrushSize())
{ // ALL SOUTH
if (startZ + zOffset == 0)
{ // SOUTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else if (startX + xOffset == 2 * v.getBrushSize()) { // ALL SOUTH
if (startZ + zOffset == 0) { // SOUTHEAST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 1;
}
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.sdirect.equalsIgnoreCase("c")) {
zOffset++;
}
else
{
} else {
xOffset--;
}
}
else if (startZ + zOffset == 2 * v.getBrushSize())
{ // SOUTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else if (startZ + zOffset == 2 * v.getBrushSize()) { // SOUTHWEST
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 1;
}
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.sdirect.equalsIgnoreCase("c")) {
xOffset--;
}
else
{
} else {
zOffset--;
}
}
else
{ // JUST PLAIN SOUTH
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else { // JUST PLAIN SOUTH
if (this.sdirect.equalsIgnoreCase("c")) {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 5;
y++;
}
zOffset++;
}
else
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 4;
y++;
}
@ -571,43 +405,29 @@ public class SpiralStaircaseBrush extends Brush
}
}
}
else if (startZ + zOffset == 0)
{ // JUST PLAIN EAST
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else if (startZ + zOffset == 0) { // JUST PLAIN EAST
if (this.sdirect.equalsIgnoreCase("c")) {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 3;
y++;
}
xOffset++;
}
else
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 2;
y++;
}
xOffset--;
}
}
else
{ // JUST PLAIN WEST
if (this.sdirect.equalsIgnoreCase("c"))
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else { // JUST PLAIN WEST
if (this.sdirect.equalsIgnoreCase("c")) {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 2;
y++;
}
xOffset--;
}
else
{
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair"))
{
} else {
if (this.stairtype.equalsIgnoreCase("woodstair") || this.stairtype.equalsIgnoreCase("cobblestair")) {
spiral[startX + xOffset][y][startZ + zOffset] = 3;
y++;
}
@ -620,58 +440,41 @@ public class SpiralStaircaseBrush extends Brush
final Undo undo = new Undo();
// 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 blockPositionY = targetBlock.getY();
int blockPositionZ = targetBlock.getZ();
switch (spiral[x][i][z])
{
switch (spiral[x][i][z]) {
case 0:
this.setBlockIdAt(blockPositionZ - v.getBrushSize() + z, blockPositionX - v.getBrushSize() + x, blockPositionY - i, BlockTypes.AIR.getInternalId());
break;
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());
}
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());
}
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());
}
break;
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());
}
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"))
{
} 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, 67, 0);
}
break;
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));
}
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));
}
break;
@ -683,20 +486,17 @@ public class SpiralStaircaseBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.digStairWell(v, this.getTargetBlock()); // make stairwell below target
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.buildStairWell(v, this.getLastBlock()); // make stairwell above target
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName("Spiral Staircase");
vm.size();
vm.voxel();
@ -708,10 +508,8 @@ public class SpiralStaircaseBrush extends Brush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
if (par[1].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
if (par[1].equalsIgnoreCase("info")) {
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 'c' (default) | 'cc' -- set the turning direction of staircase");
@ -719,8 +517,7 @@ public class SpiralStaircaseBrush extends Brush
return;
}
for (int i = 1; i < par.length; i++)
{
for (int i = 1; i < par.length; i++) {
// stairs
// step/slab
@ -729,34 +526,27 @@ public class SpiralStaircaseBrush extends Brush
this.stairtype = par[i].toLowerCase().intern();
v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype);
return;
} catch (InputParseException ignore) {}
} catch (InputParseException ignore) {
}
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();
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];
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];
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.spiralstaircase";
}
}

Datei anzeigen

@ -5,7 +5,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import java.util.Random;
@ -14,8 +13,7 @@ import java.util.Random;
*
* @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_DEFAULT = 1000;
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");
}
private void splatterBall(final SnipeData v, AsyncBlock targetBlock)
{
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
private void splatterBall(final SnipeData v, AsyncBlock targetBlock) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Seed percent set to: 10%");
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%");
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");
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];
// Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
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 x = 2 * v.getBrushSize(); x >= 0; x--) {
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) {
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];
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));
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
tempSplat[x][y][z] = splat[x][y][z]; // prime tempsplat
growcheck = 0;
if (splat[x][y][z] == 0)
{
if (x != 0 && splat[x - 1][y][z] == 1)
{
if (splat[x][y][z] == 0) {
if (x != 0 && splat[x - 1][y][z] == 1) {
growcheck++;
}
if (y != 0 && splat[x][y - 1][z] == 1)
{
if (y != 0 && splat[x][y - 1][z] == 1) {
growcheck++;
}
if (z != 0 && splat[x][y][z - 1] == 1)
{
if (z != 0 && splat[x][y][z - 1] == 1) {
growcheck++;
}
if (x != 2 * v.getBrushSize() && splat[x + 1][y][z] == 1)
{
if (x != 2 * v.getBrushSize() && splat[x + 1][y][z] == 1) {
growcheck++;
}
if (y != 2 * v.getBrushSize() && splat[x][y + 1][z] == 1)
{
if (y != 2 * v.getBrushSize() && splat[x][y + 1][z] == 1) {
growcheck++;
}
if (z != 2 * v.getBrushSize() && splat[x][y][z + 1] == 1)
{
if (z != 2 * v.getBrushSize() && splat[x][y][z + 1] == 1) {
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
}
@ -126,26 +103,20 @@ public class SplatterBallBrush extends PerformBrush
}
}
// integrate tempsplat back into splat at end of iteration
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
if (2 * v.getBrushSize() + 1 >= 0)
System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0,
2 * v.getBrushSize() + 1);
2 * v.getBrushSize() + 1);
}
}
}
this.growPercent = gref;
// Fill 1x1x1 holes
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
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 x = 2 * v.getBrushSize(); x >= 0; x--) {
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) {
splat[x][y][z] = 1;
}
}
@ -155,18 +126,14 @@ public class SplatterBallBrush extends PerformBrush
// Make the changes
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);
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);
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)
{
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) {
current.perform(targetBlock.getRelative(-v.getBrushSize() + x, -v.getBrushSize() + y, -v.getBrushSize() + z));
}
}
@ -177,30 +144,24 @@ public class SplatterBallBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.splatterBall(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.splatterBall(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
public final void info(final Message vm) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
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;
}
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;
}
vm.brushName("Splatter Ball");
@ -212,72 +173,51 @@ public class SplatterBallBrush extends PerformBrush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; 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.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 r[int] -- set a recursion (1-10). Default is 3");
return;
}
else if (parameter.startsWith("s"))
{
} else if (parameter.startsWith("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 + "%");
this.seedPercent = (int) temp;
}
else
{
} else {
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", ""));
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 + "%");
this.growPercent = (int) temp;
}
else
{
} else {
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", ""));
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);
this.splatterRecursions = temp;
}
else
{
} else {
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.splatterball";
}
}

Datei anzeigen

@ -5,7 +5,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import java.util.Random;
@ -14,8 +13,7 @@ import java.util.Random;
*
* @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_DEFAULT = 1000;
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");
}
private void splatterDisc(final SnipeData v, AsyncBlock targetBlock)
{
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
private void splatterDisc(final SnipeData v, AsyncBlock targetBlock) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%");
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%");
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");
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
}
final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
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;
}
@ -74,59 +64,46 @@ public class SplatterDiscBrush extends PerformBrush
final int gref = this.growPercent;
int growcheck;
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));
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
tempSplat[x][y] = splat[x][y]; // prime tempsplat
growcheck = 0;
if (splat[x][y] == 0)
{
if (x != 0 && splat[x - 1][y] == 1)
{
if (splat[x][y] == 0) {
if (x != 0 && splat[x - 1][y] == 1) {
growcheck++;
}
if (y != 0 && splat[x][y - 1] == 1)
{
if (y != 0 && splat[x][y - 1] == 1) {
growcheck++;
}
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1)
{
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) {
growcheck++;
}
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1)
{
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) {
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
}
}
}
// 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)
System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1);
}
}
this.growPercent = gref;
// Fill 1x1 holes
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
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)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
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) {
splat[x][y] = 1;
}
}
@ -134,13 +111,10 @@ public class SplatterDiscBrush extends PerformBrush
// Make the changes
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);
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
if (splat[x][y] == 1 && xSquared + Math.pow(y - v.getBrushSize() - 1, 2) <= rSquared)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
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()));
}
}
@ -149,30 +123,24 @@ public class SplatterDiscBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.splatterDisc(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.splatterDisc(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
public final void info(final Message vm) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
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;
}
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;
}
vm.brushName("Splatter Disc");
@ -183,69 +151,48 @@ public class SplatterDiscBrush extends PerformBrush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; 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.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 r[int] -- set a recursion (1-10). Default is 3");
return;
}
else if (parameter.startsWith("s"))
{
} else if (parameter.startsWith("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 + "%");
this.seedPercent = (int) temp;
}
else
{
} else {
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", ""));
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 + "%");
this.growPercent = (int) temp;
}
else
{
} else {
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", ""));
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);
this.splatterRecursions = temp;
}
else
{
} else {
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.splatterdisc";
}
}

Datei anzeigen

@ -15,8 +15,7 @@ import java.util.Random;
*
* @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_DEFAULT = 1000;
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");
}
@SuppressWarnings("deprecation")
private void sOverlay(final SnipeData v)
{
private void sOverlay(final SnipeData v) {
// Splatter Time
final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) {
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];
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));
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
tempSplat[x][y] = splat[x][y]; // prime tempsplat
growcheck = 0;
if (splat[x][y] == 0)
{
if (x != 0 && splat[x - 1][y] == 1)
{
if (splat[x][y] == 0) {
if (x != 0 && splat[x - 1][y] == 1) {
growcheck++;
}
if (y != 0 && splat[x][y - 1] == 1)
{
if (y != 0 && splat[x][y - 1] == 1) {
growcheck++;
}
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1)
{
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) {
growcheck++;
}
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1)
{
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) {
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
}
}
}
// 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)
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 double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2);
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--)
{
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--)
{
for (int y = this.getTargetBlock().getY(); y > 0; y--)
{
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
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 (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 && 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
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
// 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.
BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z));
BlockMaterial mat = type.getMaterial();
@ -151,14 +128,10 @@ public class SplatterOverlayBrush extends PerformBrush
} else {
continue;
}
}
else
{
} else {
final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth;
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())
{
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()) {
// 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));
// 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());
}
private void soverlayTwo(final SnipeData v)
{
private void soverlayTwo(final SnipeData v) {
// Splatter Time
final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) {
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];
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));
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
tempsplat[x][y] = splat[x][y]; // prime tempsplat
growcheck = 0;
if (splat[x][y] == 0)
{
if (x != 0 && splat[x - 1][y] == 1)
{
if (splat[x][y] == 0) {
if (x != 0 && splat[x - 1][y] == 1) {
growcheck++;
}
if (y != 0 && splat[x][y - 1] == 1)
{
if (y != 0 && splat[x][y - 1] == 1) {
growcheck++;
}
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1)
{
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) {
growcheck++;
}
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1)
{
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) {
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
}
@ -236,8 +196,7 @@ public class SplatterOverlayBrush extends PerformBrush
}
// 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)
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 double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2);
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--)
{
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
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
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
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
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.
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 = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z));
BlockMaterial mat = type.getMaterial();
if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer())
{
final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth;
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 parameters
memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column.
}
continue;
if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer()) {
final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth;
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 parameters
memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column.
}
continue;
} else {
continue;
}
}
else
{
} else {
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
// parameters
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
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.sOverlay(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.soverlayTwo(v);
}
@Override
public final void info(final Message vm)
{
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
public final void info(final Message vm) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
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;
}
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;
}
vm.brushName(this.getName());
@ -337,15 +278,11 @@ public class SplatterOverlayBrush extends PerformBrush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
final String parameter = par[i];
try
{
if (parameter.equalsIgnoreCase("info"))
{
try {
if (parameter.equalsIgnoreCase("info")) {
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.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 r[int] -- set a recursion (1-10). Default is 3");
return;
}
else if (parameter.startsWith("d"))
{
} else if (parameter.startsWith("d")) {
this.depth = Integer.parseInt(parameter.replace("d", ""));
v.sendMessage(ChatColor.AQUA + "Depth set to " + this.depth);
if (this.depth < 1)
{
if (this.depth < 1) {
this.depth = 1;
}
}
else if (parameter.startsWith("all"))
{
} else if (parameter.startsWith("all")) {
this.allBlocks = true;
v.sendMessage(ChatColor.BLUE + "Will overlay over any block." + this.depth);
}
else if (parameter.startsWith("some"))
{
} else if (parameter.startsWith("some")) {
this.allBlocks = false;
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", ""));
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 + "%");
this.seedPercent = (int) temp;
}
else
{
} else {
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", ""));
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 + "%");
this.growPercent = (int) temp;
}
else
{
} else {
v.sendMessage(ChatColor.RED + "Growth percent must be an integer 1-9999!");
}
}
else if (parameter.startsWith("randh"))
{
} else if (parameter.startsWith("randh")) {
randomizeHeight = !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", ""));
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);
this.splatterRecursions = temp;
}
else
{
} else {
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", ""));
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);
this.yOffset = temp;
}
else
{
} else {
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.");
}
}
catch (Exception exception)
{
} catch (Exception exception) {
v.sendMessage(String.format("An error occured while processing parameter %s.", parameter));
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.splatteroverlay";
}
}

Datei anzeigen

@ -5,7 +5,6 @@ import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import java.util.Random;
@ -14,8 +13,7 @@ import java.util.Random;
*
* @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_DEFAULT = 1000;
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");
}
private void vSplatterBall(final SnipeData v, AsyncBlock targetBlock)
{
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
private void vSplatterBall(final SnipeData v, AsyncBlock targetBlock) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%");
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%");
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");
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
}
final int[][][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
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 x = 2 * v.getBrushSize(); x >= 0; x--) {
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) {
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];
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));
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
for (int z = 2 * v.getBrushSize(); z >= 0; z--) {
tempSplat[x][y][z] = splat[x][y][z]; // prime tempsplat
growcheck = 0;
if (splat[x][y][z] == 0)
{
if (x != 0 && splat[x - 1][y][z] == 1)
{
if (splat[x][y][z] == 0) {
if (x != 0 && splat[x - 1][y][z] == 1) {
growcheck++;
}
if (y != 0 && splat[x][y - 1][z] == 1)
{
if (y != 0 && splat[x][y - 1][z] == 1) {
growcheck++;
}
if (z != 0 && splat[x][y][z - 1] == 1)
{
if (z != 0 && splat[x][y][z - 1] == 1) {
growcheck++;
}
if (x != 2 * v.getBrushSize() && splat[x + 1][y][z] == 1)
{
if (x != 2 * v.getBrushSize() && splat[x + 1][y][z] == 1) {
growcheck++;
}
if (y != 2 * v.getBrushSize() && splat[x][y + 1][z] == 1)
{
if (y != 2 * v.getBrushSize() && splat[x][y + 1][z] == 1) {
growcheck++;
}
if (z != 2 * v.getBrushSize() && splat[x][y][z + 1] == 1)
{
if (z != 2 * v.getBrushSize() && splat[x][y][z + 1] == 1) {
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
}
@ -126,26 +103,20 @@ public class SplatterVoxelBrush extends PerformBrush
}
}
// integrate tempsplat back into splat at end of iteration
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
if (2 * v.getBrushSize() + 1 >= 0)
System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0,
2 * v.getBrushSize() + 1);
2 * v.getBrushSize() + 1);
}
}
}
this.growPercent = gref;
// Fill 1x1x1 holes
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
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 x = 2 * v.getBrushSize(); x >= 0; x--) {
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) {
splat[x][y][z] = 1;
}
}
@ -154,14 +125,10 @@ public class SplatterVoxelBrush extends PerformBrush
// Make the changes
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
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 x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
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));
}
}
@ -171,30 +138,24 @@ public class SplatterVoxelBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.vSplatterBall(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.vSplatterBall(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
public final void info(final Message vm) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
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;
}
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;
}
vm.brushName("Splatter Voxel");
@ -205,69 +166,48 @@ public class SplatterVoxelBrush extends PerformBrush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; 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.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 r[int] -- set a recursion (1-10). Default is 3");
return;
}
else if (parameter.startsWith("s"))
{
} else if (parameter.startsWith("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 + "%");
this.seedPercent = (int) temp;
}
else
{
} else {
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", ""));
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 + "%");
this.growPercent = (int) temp;
}
else
{
} else {
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", ""));
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);
this.splatterRecursions = temp;
}
else
{
} else {
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.splattervoxel";
}
}

Datei anzeigen

@ -13,8 +13,7 @@ import java.util.Random;
*
* @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_DEFAULT = 1000;
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");
}
private void vSplatterDisc(final SnipeData v, Block targetBlock)
{
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
private void vSplatterDisc(final SnipeData v, Block targetBlock) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
v.sendMessage(ChatColor.BLUE + "Seed percent set to: 10%");
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%");
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");
this.splatterRecursions = SPLATREC_PERCENT_DEFAULT;
}
final int[][] splat = new int[2 * v.getBrushSize() + 1][2 * v.getBrushSize() + 1];
// Seed the array
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
if (this.generator.nextInt(SEED_PERCENT_MAX + 1) <= this.seedPercent) {
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];
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));
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
tempSplat[x][y] = splat[x][y]; // prime tempsplat
growcheck = 0;
if (splat[x][y] == 0)
{
if (x != 0 && splat[x - 1][y] == 1)
{
if (splat[x][y] == 0) {
if (x != 0 && splat[x - 1][y] == 1) {
growcheck++;
}
if (y != 0 && splat[x][y - 1] == 1)
{
if (y != 0 && splat[x][y - 1] == 1) {
growcheck++;
}
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1)
{
if (x != 2 * v.getBrushSize() && splat[x + 1][y] == 1) {
growcheck++;
}
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1)
{
if (y != 2 * v.getBrushSize() && splat[x][y + 1] == 1) {
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
}
}
}
// 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)
System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1);
}
}
this.growPercent = gref;
// Fill 1x1 holes
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
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)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
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) {
splat[x][y] = 1;
}
}
@ -130,12 +108,9 @@ public class SplatterVoxelDiscBrush extends PerformBrush
// Make the changes
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
{
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
{
if (splat[x][y] == 1)
{
for (int x = 2 * v.getBrushSize(); x >= 0; x--) {
for (int y = 2 * v.getBrushSize(); y >= 0; y--) {
if (splat[x][y] == 1) {
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
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.vSplatterDisc(v, this.getTargetBlock());
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.vSplatterDisc(v, this.getLastBlock());
}
@Override
public final void info(final Message vm)
{
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX)
{
public final void info(final Message vm) {
if (this.seedPercent < SEED_PERCENT_MIN || this.seedPercent > SEED_PERCENT_MAX) {
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;
}
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;
}
vm.brushName("Splatter Voxel Disc");
@ -179,70 +148,49 @@ public class SplatterVoxelDiscBrush extends PerformBrush
}
@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];
if (parameter.equalsIgnoreCase("info"))
{
if (parameter.equalsIgnoreCase("info")) {
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 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");
return;
}
else if (parameter.startsWith("s"))
{
} else if (parameter.startsWith("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 + "%");
this.seedPercent = (int) temp;
}
else
{
} else {
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", ""));
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 + "%");
this.growPercent = (int) temp;
}
else
{
} else {
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", ""));
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);
this.splatterRecursions = temp;
}
else
{
} else {
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.splattervoxeldisc";
}
}

Datei anzeigen

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

Datei anzeigen

@ -1,99 +1,52 @@
package com.thevoxelbox.voxelsniper.brush;
import java.util.HashSet;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import java.util.HashSet;
/**
*
*/
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
}
public class StampBrush extends Brush {
protected HashSet<BlockWrapper> clone = new HashSet<>();
protected HashSet<BlockWrapper> fall = new HashSet<>();
protected HashSet<BlockWrapper> drop = new HashSet<>();
protected HashSet<BlockWrapper> solid = new HashSet<>();
protected Undo undo;
protected boolean sorted = false;
protected StampType stamp = StampType.DEFAULT;
/**
*
*/
public StampBrush()
{
public StampBrush() {
this.setName("Stamp");
}
/**
*
*/
public final void reSort()
{
public final void reSort() {
this.sorted = false;
}
/**
* @param id
*
* @return
*/
protected final boolean falling(final int id)
{
protected final boolean falling(final int id) {
return (id > 7 && id < 14);
}
/**
* @param id
*
* @return
*/
protected final boolean fallsOff(final int id)
{
protected final boolean fallsOff(final int id) {
return (BlockTypes.get(id).getMaterial().isFragileWhenPushed());
}
@ -101,8 +54,7 @@ public class StampBrush extends Brush
* @param cb
*/
@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);
this.undo.put(block);
block.setTypeId(cb.id);
@ -113,11 +65,9 @@ public class StampBrush extends Brush
* @param cb
*/
@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);
if (block.isEmpty())
{
if (block.isEmpty()) {
this.undo.put(block);
block.setTypeId(cb.id);
block.setPropertyId(cb.d);
@ -127,60 +77,44 @@ public class StampBrush extends Brush
/**
* @param type
*/
protected final void setStamp(final StampType type)
{
protected final void setStamp(final StampType type) {
this.stamp = type;
}
/**
* @param v
*/
protected final void stamp(final SnipeData v)
{
protected final void stamp(final SnipeData v) {
this.undo = new Undo();
if (this.sorted)
{
for (final BlockWrapper block : this.solid)
{
if (this.sorted) {
for (final BlockWrapper block : this.solid) {
this.setBlock(block);
}
for (final BlockWrapper block : this.drop)
{
for (final BlockWrapper block : this.drop) {
this.setBlock(block);
}
for (final BlockWrapper block : this.fall)
{
for (final BlockWrapper block : this.fall) {
this.setBlock(block);
}
}
else
{
} else {
this.fall.clear();
this.drop.clear();
this.solid.clear();
for (final BlockWrapper block : this.clone)
{
if (this.fallsOff(block.id))
{
for (final BlockWrapper block : this.clone) {
if (this.fallsOff(block.id)) {
this.fall.add(block);
}
else if (this.falling(block.id))
{
} else if (this.falling(block.id)) {
this.drop.add(block);
}
else
{
} else {
this.solid.add(block);
this.setBlock(block);
}
}
for (final BlockWrapper block : this.drop)
{
for (final BlockWrapper block : this.drop) {
this.setBlock(block);
}
for (final BlockWrapper block : this.fall)
{
for (final BlockWrapper block : this.fall) {
this.setBlock(block);
}
this.sorted = true;
@ -192,53 +126,38 @@ public class StampBrush extends Brush
/**
* @param v
*/
protected final void stampFill(final SnipeData v)
{
protected final void stampFill(final SnipeData v) {
this.undo = new Undo();
if (this.sorted)
{
for (final BlockWrapper block : this.solid)
{
if (this.sorted) {
for (final BlockWrapper block : this.solid) {
this.setBlockFill(block);
}
for (final BlockWrapper block : this.drop)
{
for (final BlockWrapper block : this.drop) {
this.setBlockFill(block);
}
for (final BlockWrapper block : this.fall)
{
for (final BlockWrapper block : this.fall) {
this.setBlockFill(block);
}
}
else
{
} else {
this.fall.clear();
this.drop.clear();
this.solid.clear();
for (final BlockWrapper block : this.clone)
{
if (this.fallsOff(block.id))
{
for (final BlockWrapper block : this.clone) {
if (this.fallsOff(block.id)) {
this.fall.add(block);
}
else if (this.falling(block.id))
{
} else if (this.falling(block.id)) {
this.drop.add(block);
}
else if (block.id != 0)
{
} else if (block.id != 0) {
this.solid.add(block);
this.setBlockFill(block);
}
}
for (final BlockWrapper block : this.drop)
{
for (final BlockWrapper block : this.drop) {
this.setBlockFill(block);
}
for (final BlockWrapper block : this.fall)
{
for (final BlockWrapper block : this.fall) {
this.setBlockFill(block);
}
this.sorted = true;
@ -250,53 +169,38 @@ public class StampBrush extends Brush
/**
* @param v
*/
protected final void stampNoAir(final SnipeData v)
{
protected final void stampNoAir(final SnipeData v) {
this.undo = new Undo();
if (this.sorted)
{
for (final BlockWrapper block : this.solid)
{
if (this.sorted) {
for (final BlockWrapper block : this.solid) {
this.setBlock(block);
}
for (final BlockWrapper block : this.drop)
{
for (final BlockWrapper block : this.drop) {
this.setBlock(block);
}
for (final BlockWrapper block : this.fall)
{
for (final BlockWrapper block : this.fall) {
this.setBlock(block);
}
}
else
{
} else {
this.fall.clear();
this.drop.clear();
this.solid.clear();
for (final BlockWrapper block : this.clone)
{
if (this.fallsOff(block.id))
{
for (final BlockWrapper block : this.clone) {
if (this.fallsOff(block.id)) {
this.fall.add(block);
}
else if (this.falling(block.id))
{
} else if (this.falling(block.id)) {
this.drop.add(block);
}
else if (block.id != 0)
{
} else if (block.id != 0) {
this.solid.add(block);
this.setBlock(block);
}
}
for (final BlockWrapper block : this.drop)
{
for (final BlockWrapper block : this.drop) {
this.setBlock(block);
}
for (final BlockWrapper block : this.fall)
{
for (final BlockWrapper block : this.fall) {
this.setBlock(block);
}
this.sorted = true;
@ -306,10 +210,8 @@ public class StampBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
switch (this.stamp)
{
protected final void arrow(final SnipeData v) {
switch (this.stamp) {
case DEFAULT:
this.stamp(v);
break;
@ -329,20 +231,50 @@ public class StampBrush extends Brush
}
@Override
protected void powder(final SnipeData v)
{
protected void powder(final SnipeData v) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void info(final Message vm)
{
public void info(final Message vm) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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;
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.object.FaweInputStream;
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.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
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
@ -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,
* 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. )
*
* <p>
* TODO: Make limit a config option
*
* @author Gavjenks
*/
public class StencilBrush extends Brush
{
public class StencilBrush extends Brush {
private byte pasteOption = 1; // 0 = full, 1 = fill, 2 = replace
private String filename = "NoFileLoaded";
private short x;
@ -54,16 +45,13 @@ public class StencilBrush extends Brush
/**
*
*/
public StencilBrush()
{
public StencilBrush() {
this.setName("Stencil");
}
@SuppressWarnings("deprecation")
private void stencilPaste(final SnipeData v)
{
if (this.filename.matches("NoFileLoaded"))
{
private void stencilPaste(final SnipeData v) {
if (this.filename.matches("NoFileLoaded")) {
v.sendMessage(ChatColor.RED + "You did not specify a filename. This is required.");
return;
}
@ -71,10 +59,8 @@ public class StencilBrush extends Brush
final Undo undo = new Undo();
final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil");
if (file.exists())
{
try
{
if (file.exists()) {
try {
final FaweInputStream in = new FaweInputStream(new DataInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file)))));
this.x = in.readShort();
@ -95,145 +81,109 @@ public class StencilBrush extends Brush
int blockPositionX = getTargetBlock().getX();
int blockPositionY = getTargetBlock().getY();
int blockPositionZ = getTargetBlock().getZ();
if (this.pasteOption == 0)
{
for (int i = 1; i < numRuns + 1; i++)
{
if (in.readBoolean())
{
if (this.pasteOption == 0) {
for (int i = 1; i < numRuns + 1; i++) {
if (in.readBoolean()) {
final int numLoops = in.readByte() + 128;
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));
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id);
currX++;
if (currX == this.x - this.xRef)
{
if (currX == this.x - this.xRef) {
currX = -this.xRef;
currZ++;
if (currZ == this.z - this.zRef)
{
if (currZ == this.z - this.zRef) {
currZ = -this.zRef;
currY++;
}
}
}
}
else
{
} else {
undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ));
int combined = in.readVarInt();
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(combined);
currX++;
if (currX == this.x - this.xRef)
{
if (currX == this.x - this.xRef) {
currX = -this.xRef;
currZ++;
if (currZ == this.z - this.zRef)
{
if (currZ == this.z - this.zRef) {
currZ = -this.zRef;
currY++;
}
}
}
}
}
else if (this.pasteOption == 1)
{
for (int i = 1; i < numRuns + 1; i++)
{
if (in.readBoolean())
{
} else if (this.pasteOption == 1) {
for (int i = 1; i < numRuns + 1; i++) {
if (in.readBoolean()) {
final int numLoops = in.readByte() + 128;
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));
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id);
}
currX++;
if (currX == this.x - this.xRef)
{
if (currX == this.x - this.xRef) {
currX = -this.xRef;
currZ++;
if (currZ == this.z - this.zRef)
{
if (currZ == this.z - this.zRef) {
currZ = -this.zRef;
currY++;
}
}
}
}
else
{
} else {
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));
// v.sendMessage("currX:" + currX + " currZ:"+currZ + " currY:" + currY + " id:" + id + " data:" + data);
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id);
}
currX++;
if (currX == this.x - this.xRef)
{
if (currX == this.x - this.xRef) {
currX = -this.xRef;
currZ++;
if (currZ == this.z - this.zRef)
{
if (currZ == this.z - this.zRef) {
currZ = -this.zRef;
currY++;
}
}
}
}
}
else
{ // replace
for (int i = 1; i < numRuns + 1; i++)
{
if (in.readBoolean())
{
} else { // replace
for (int i = 1; i < numRuns + 1; i++) {
if (in.readBoolean()) {
final int numLoops = in.readByte() + 128;
id = (in.readVarInt());
for (int j = 0; j < (numLoops); j++)
{
if (!BlockTypes.getFromStateId(id).getMaterial().isAir())
{
for (int j = 0; j < (numLoops); j++) {
if (!BlockTypes.getFromStateId(id).getMaterial().isAir()) {
undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ));
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id);
}
currX++;
if (currX == this.x - this.xRef)
{
if (currX == this.x - this.xRef) {
currX = -this.xRef;
currZ++;
if (currZ == this.z - this.zRef)
{
if (currZ == this.z - this.zRef) {
currZ = -this.zRef;
currY++;
}
}
}
}
else
{
} else {
id = (in.readVarInt());
if (id != 0)
{
if (id != 0) {
undo.put(this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ));
this.clampY(blockPositionX + currX, blockPositionY + currY, blockPositionZ + currZ).setCombinedId(id);
}
currX++;
if (currX == this.x)
{
if (currX == this.x) {
currX = 0;
currZ++;
if (currZ == this.z)
{
if (currZ == this.z) {
currZ = 0;
currY++;
}
@ -244,26 +194,20 @@ public class StencilBrush extends Brush
in.close();
v.owner().storeUndo(undo);
}
catch (final Exception exception)
{
} catch (final Exception exception) {
v.sendMessage(ChatColor.RED + "Something went wrong.");
exception.printStackTrace();
}
}
else
{
} else {
v.sendMessage(ChatColor.RED + "You need to type a stencil name / your specified stencil does not exist.");
}
}
@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");
try
{
try {
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.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.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.");
return;
}
@ -299,24 +242,18 @@ public class StencilBrush extends Brush
int thisId;
int counter = 0;
int arrayIndex = 0;
for (int y = 0; y < this.y; y++)
{
for (int z = 0; z < this.z; z++)
{
for (int x = 0; x < this.x; x++)
{
for (int y = 0; y < this.y; y++) {
for (int z = 0; z < this.z; z++) {
for (int x = 0; x < this.x; x++) {
AsyncBlock currentBlock = getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ + z);
thisId = (currentBlock.getCombinedId());
if (thisId != lastId || counter == 255)
{
if (thisId != lastId || counter == 255) {
blockArray[arrayIndex] = lastId;
runSizeArray[arrayIndex] = (byte) (counter - 128);
arrayIndex++;
counter = 1;
lastId = thisId;
}
else
{
} else {
counter++;
lastId = thisId;
}
@ -328,16 +265,12 @@ public class StencilBrush extends Brush
out.writeInt(arrayIndex + 1);
// v.sendMessage("number of runs = " + arrayIndex);
for (int i = 0; i < arrayIndex + 1; i++)
{
if (runSizeArray[i] > -127)
{
for (int i = 0; i < arrayIndex + 1; i++) {
if (runSizeArray[i] > -127) {
out.writeBoolean(true);
out.writeByte(runSizeArray[i]);
out.writeVarInt(blockArray[i]);
}
else
{
} else {
out.writeBoolean(false);
out.writeVarInt(blockArray[i]);
}
@ -346,45 +279,34 @@ public class StencilBrush extends Brush
v.sendMessage(ChatColor.BLUE + "Saved as '" + this.filename + "'.");
out.close();
}
catch (final Exception exception)
{
} catch (final Exception exception) {
v.sendMessage(ChatColor.RED + "Something went wrong.");
exception.printStackTrace();
}
}
@Override
protected final void arrow(final SnipeData v)
{ // will be used to copy/save later on?
if (this.point == 1)
{
protected final void arrow(final SnipeData v) { // will be used to copy/save later on?
if (this.point == 1) {
this.firstPoint[0] = this.getTargetBlock().getX();
this.firstPoint[1] = this.getTargetBlock().getZ();
this.firstPoint[2] = this.getTargetBlock().getY();
v.sendMessage(ChatColor.GRAY + "First point");
v.sendMessage("X:" + this.firstPoint[0] + " Z:" + this.firstPoint[1] + " Y:" + this.firstPoint[2]);
this.point = 2;
}
else if (this.point == 2)
{
} else if (this.point == 2) {
this.secondPoint[0] = this.getTargetBlock().getX();
this.secondPoint[1] = this.getTargetBlock().getZ();
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)");
this.point = 1;
}
else
{
} else {
v.sendMessage(ChatColor.GRAY + "Second point");
v.sendMessage("X:" + this.secondPoint[0] + " Z:" + this.secondPoint[1] + " Y:" + this.secondPoint[2]);
this.point = 3;
}
}
else if (this.point == 3)
{
} else if (this.point == 3) {
this.pastePoint[0] = this.getTargetBlock().getX();
this.pastePoint[1] = this.getTargetBlock().getZ();
this.pastePoint[2] = this.getTargetBlock().getY();
@ -397,65 +319,48 @@ public class StencilBrush extends Brush
}
@Override
protected final void powder(final SnipeData v)
{ // will be used to paste later on
protected final void powder(final SnipeData v) { // will be used to paste later on
this.stencilPaste(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.custom("File loaded: " + this.filename);
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
if (par[1].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
if (par[1].equalsIgnoreCase("info")) {
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.BLUE + "Size of the stencils you are allowed to paste depends on rank (member / lite, sniper, curator, admin)");
return;
}
else if (par[1].equalsIgnoreCase("full"))
{
} else if (par[1].equalsIgnoreCase("full")) {
this.pasteOption = 0;
this.pasteParam = 1;
}
else if (par[1].equalsIgnoreCase("fill"))
{
} else if (par[1].equalsIgnoreCase("fill")) {
this.pasteOption = 1;
this.pasteParam = 1;
}
else if (par[1].equalsIgnoreCase("replace"))
{
} else if (par[1].equalsIgnoreCase("replace")) {
this.pasteOption = 2;
this.pasteParam = 1;
}
try
{
try {
this.filename = par[1 + this.pasteParam];
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.");
}
else
{
} else {
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.");
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.stencil";
}
}

Datei anzeigen

@ -12,8 +12,7 @@ import org.bukkit.util.Vector;
*
* @author Giltwist
*/
public class ThreePointCircleBrush extends PerformBrush
{
public class ThreePointCircleBrush extends PerformBrush {
private Vector coordsOne;
private Vector coordsTwo;
private Vector coordsThree;
@ -22,31 +21,22 @@ public class ThreePointCircleBrush extends PerformBrush
/**
* Default Constructor.
*/
public ThreePointCircleBrush()
{
public ThreePointCircleBrush() {
this.setName("3-Point Circle");
}
@Override
protected final void arrow(final SnipeData v)
{
if (this.coordsOne == null)
{
protected final void arrow(final SnipeData v) {
if (this.coordsOne == null) {
this.coordsOne = this.getTargetBlock().getLocation().toVector();
v.sendMessage(ChatColor.GRAY + "First Corner set.");
}
else if (this.coordsTwo == null)
{
} else if (this.coordsTwo == null) {
this.coordsTwo = this.getTargetBlock().getLocation().toVector();
v.sendMessage(ChatColor.GRAY + "Second Corner set.");
}
else if (this.coordsThree == null)
{
} else if (this.coordsThree == null) {
this.coordsThree = this.getTargetBlock().getLocation().toVector();
v.sendMessage(ChatColor.GRAY + "Third Corner set.");
}
else
{
} else {
this.coordsOne = this.getTargetBlock().getLocation().toVector();
this.coordsTwo = null;
this.coordsThree = null;
@ -55,10 +45,8 @@ public class ThreePointCircleBrush extends PerformBrush
}
@Override
protected final void powder(final SnipeData v)
{
if (this.coordsOne == null || this.coordsTwo == null || this.coordsThree == null)
{
protected final void powder(final SnipeData v) {
if (this.coordsOne == null || this.coordsTwo == null || this.coordsThree == null) {
return;
}
@ -71,8 +59,7 @@ public class ThreePointCircleBrush extends PerformBrush
vectorThree.subtract(vectorTwo);
// 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.");
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 int brushSize = NumberConversions.ceil(radius) + 1;
for (int x = -brushSize; x <= brushSize; x++)
{
for (int y = -brushSize; y <= brushSize; y++)
{
for (int z = -brushSize; z <= brushSize; z++)
{
for (int x = -brushSize; x <= brushSize; x++) {
for (int y = -brushSize; y <= brushSize; y++) {
for (int z = -brushSize; z <= brushSize; z++) {
// Calculate distance from center
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);
// 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));
}
@ -153,11 +136,9 @@ public class ThreePointCircleBrush extends PerformBrush
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
switch (this.tolerance)
{
switch (this.tolerance) {
case ACCURATE:
vm.custom(ChatColor.GOLD + "Mode: Accurate");
break;
@ -175,16 +156,12 @@ public class ThreePointCircleBrush extends PerformBrush
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
if (par[1].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
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.");
String toleranceOptions = "";
for (final Tolerance tolerance : Tolerance.values())
{
if (!toleranceOptions.isEmpty())
{
for (final Tolerance tolerance : Tolerance.values()) {
if (!toleranceOptions.isEmpty()) {
toleranceOptions += "|";
}
toleranceOptions += tolerance.name().toLowerCase();
@ -193,46 +170,38 @@ public class ThreePointCircleBrush extends PerformBrush
return;
}
for (int i = 1; i < par.length; i++)
{
for (int i = 1; i < par.length; i++) {
final String parameter = par[i].toUpperCase();
try
{
try {
this.tolerance = Tolerance.valueOf(parameter);
v.sendMessage(ChatColor.AQUA + "Brush set to " + this.tolerance.name().toLowerCase() + " tolerance.");
return;
}
catch (final IllegalArgumentException exception)
{
} catch (final IllegalArgumentException exception) {
v.getVoxelMessage().brushMessage("No such tolerance.");
}
}
}
@Override
public String getPermissionNode() {
return "voxelsniper.brush.threepointcircle";
}
/**
* Enumeration on Tolerance values.
*
* @author MikeMatrix
*/
private enum Tolerance
{
private enum Tolerance {
DEFAULT(1000), ACCURATE(10), SMOOTH(2000);
private int value;
Tolerance(final int value)
{
Tolerance(final int value) {
this.value = value;
}
public int getValue()
{
public int getValue() {
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.Material;
import org.bukkit.TreeType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
/**
@ -20,21 +18,18 @@ import org.bukkit.block.BlockState;
*
* @author Mick
*/
public class TreeSnipeBrush extends Brush
{
public class TreeSnipeBrush extends Brush {
private TreeType treeType = TreeType.TREE;
/**
*
*/
public TreeSnipeBrush()
{
public TreeSnipeBrush() {
this.setName("Tree Snipe");
}
@SuppressWarnings("deprecation")
private void single(final SnipeData v, AsyncBlock targetBlock)
{
private void single(final SnipeData v, AsyncBlock targetBlock) {
UndoDelegate undoDelegate = new UndoDelegate(targetBlock.getWorld());
AsyncBlock blockBelow = targetBlock.getRelative(BlockFace.DOWN);
AsyncBlockState currentState = blockBelow.getState();
@ -47,31 +42,23 @@ public class TreeSnipeBrush extends Brush
v.owner().storeUndo(undo);
}
private int getYOffset()
{
for (int i = 1; i < (getTargetBlock().getWorld().getMaxHeight() - 1 - getTargetBlock().getY()); i++)
{
if (Objects.equal(getTargetBlock().getRelative(0, i + 1, 0).getType(), Material.AIR))
{
private int getYOffset() {
for (int i = 1; i < (getTargetBlock().getWorld().getMaxHeight() - 1 - getTargetBlock().getY()); i++) {
if (Objects.equal(getTargetBlock().getRelative(0, i + 1, 0).getType(), Material.AIR)) {
return i;
}
}
return 0;
}
private void printTreeType(final Message vm)
{
private void printTreeType(final Message vm) {
String printout = "";
boolean delimiterHelper = true;
for (final TreeType treeType : TreeType.values())
{
if (delimiterHelper)
{
for (final TreeType treeType : TreeType.values()) {
if (delimiterHelper) {
delimiterHelper = false;
}
else
{
} else {
printout += ", ";
}
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
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
AsyncBlock targetBlock = getTargetBlock().getRelative(0, getYOffset(), 0);
this.single(v, targetBlock);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.single(v, getTargetBlock());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
this.printTreeType(vm);
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
if (par[i].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) {
v.sendMessage(ChatColor.GOLD + "Tree snipe brush:");
v.sendMessage(ChatColor.AQUA + "/b t treetype");
this.printTreeType(v.getVoxelMessage());
return;
}
try
{
try {
this.treeType = TreeType.valueOf(par[i].toUpperCase());
this.printTreeType(v.getVoxelMessage());
}
catch (final IllegalArgumentException exception)
{
} catch (final IllegalArgumentException exception) {
v.getVoxelMessage().brushMessage("No such tree type.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.treesnipe";
}
}

Datei anzeigen

@ -10,8 +10,7 @@ import org.bukkit.ChatColor;
*
* @author Giltwist
*/
public class TriangleBrush extends PerformBrush
{
public class TriangleBrush extends PerformBrush {
private double[] coordsOne = new double[3]; // Three corners
private double[] coordsTwo = 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");
}
private void triangleA(final SnipeData v)
{
switch (this.cornernumber)
{
private void triangleA(final SnipeData v) {
switch (this.cornernumber) {
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
// 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 lengthTwo = 0;
double lengthThree = 0;
double heronBig = 0;
// 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.vectorTwo[i] = this.coordsThree[i] - this.coordsOne[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
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.");
}
else
{
} else {
// Make the Changes
final double[] cVectorOne = new double[3];
final double[] cVectorTwo = new double[3];
final double[] cVectorThree = new double[3];
for (int y = -brushSize; y <= brushSize; y++)
{ // X DEPENDENT
for (int z = -brushSize; z <= brushSize; z++)
{
for (int y = -brushSize; y <= brushSize; y++) { // X DEPENDENT
for (int z = -brushSize; z <= brushSize; z++) {
this.currentCoords[1] = this.coordsOne[1] + y;
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];
// 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];
cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[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);
// 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];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[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);
// 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];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[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;
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]));
@ -167,17 +152,14 @@ public class TriangleBrush extends PerformBrush
}
} // END X DEPENDENT
for (int x = -brushSize; x <= brushSize; x++)
{ // Y DEPENDENT
for (int z = -brushSize; z <= brushSize; z++)
{
for (int x = -brushSize; x <= brushSize; x++) { // Y DEPENDENT
for (int z = -brushSize; z <= brushSize; z++) {
this.currentCoords[0] = this.coordsOne[0] + x;
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];
// 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];
cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[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);
// 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];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[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);
// 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];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[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;
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]));
@ -223,17 +202,14 @@ public class TriangleBrush extends PerformBrush
}
} // END Y DEPENDENT
for (int x = -brushSize; x <= brushSize; x++)
{ // Z DEPENDENT
for (int y = -brushSize; y <= brushSize; y++)
{
for (int x = -brushSize; x <= brushSize; x++) { // Z DEPENDENT
for (int y = -brushSize; y <= brushSize; y++) {
this.currentCoords[0] = this.coordsOne[0] + x;
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];
// 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];
cVectorTwo[i] = this.currentCoords[i] - this.coordsOne[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);
// 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];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[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);
// 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];
cVectorTwo[i] = this.currentCoords[i] - this.coordsThree[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);
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]));
}
}
@ -299,36 +272,30 @@ public class TriangleBrush extends PerformBrush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.triangleA(v);
}
@Override
protected final void powder(final SnipeData v)
{ // Add a point
protected final void powder(final SnipeData v) { // Add a point
this.triangleP(v);
}
@Override
public final void info(final Message vm)
{ // Make the triangle
public final void info(final Message vm) { // Make the triangle
vm.brushName(this.getName());
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
if (par[1].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
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.");
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
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
*/
public class UnderlayBrush extends PerformBrush
{
public class UnderlayBrush extends PerformBrush {
private static final int DEFAULT_DEPTH = 3;
private int depth = DEFAULT_DEPTH;
private boolean allBlocks = false;
@ -22,29 +21,21 @@ public class UnderlayBrush extends PerformBrush
/**
*
*/
public UnderlayBrush()
{
public UnderlayBrush() {
this.setName("Underlay (Reverse Overlay)");
}
@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 double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2);
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--)
{
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
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.
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
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
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);
BlockMaterial mat = BlockTypes.get(id).getMaterial();
if (!mat.isReplacedDuringPlacement() && mat.isFullCube()) {
@ -60,13 +51,9 @@ public class UnderlayBrush extends PerformBrush
} else {
continue;
}
}
else
{
for (int d = 0; (d < this.depth); d++)
{
if (!this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z).isEmpty())
{
} else {
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
// parameters
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());
}
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 double brushSizeSquared = Math.pow(v.getBrushSize() + 0.5, 2);
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--)
{
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
if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared)
{ // if inside of the column...
for (int z = v.getBrushSize(); z >= -v.getBrushSize(); z--) {
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
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.
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);
BlockMaterial mat = BlockTypes.get(id).getMaterial();
@ -114,11 +94,8 @@ public class UnderlayBrush extends PerformBrush
} else {
continue;
}
}
else
{
for (int d = -1; (d < this.depth - 1); d++)
{
} else {
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
// parameters
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
public final void arrow(final SnipeData v)
{
public final void arrow(final SnipeData v) {
this.underlay(v);
}
@Override
public final void powder(final SnipeData v)
{
public final void powder(final SnipeData v) {
this.underlay2(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
}
@Override
public final void parameters(final String[] par, final SnipeData v)
{
for (int i = 1; i < par.length; i++)
{
if (par[i].equalsIgnoreCase("info"))
{
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 1; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) {
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.BLUE + "all (ex: /b reover all) Sets the brush to affect ALL materials");
if (this.depth < 1)
{
if (this.depth < 1) {
this.depth = 1;
}
return;
}
if (par[i].startsWith("d"))
{
if (par[i].startsWith("d")) {
this.depth = Integer.parseInt(par[i].replace("d", ""));
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;
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;
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.");
}
}
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.underlay";
}
}

Datei anzeigen

@ -12,26 +12,22 @@ import org.bukkit.block.BlockFace;
*
* @author Gavjenks
*/
public class VoltMeterBrush extends Brush
{
public class VoltMeterBrush extends Brush {
/**
*
*/
public VoltMeterBrush()
{
public VoltMeterBrush() {
this.setName("VoltMeter");
}
@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 int data = block.getPropertyId();
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 boolean indirect = block.isBlockIndirectlyPowered();
final boolean direct = block.isBlockPowered();
@ -45,27 +41,23 @@ public class VoltMeterBrush extends Brush
}
@Override
protected final void arrow(final SnipeData v)
{
protected final void arrow(final SnipeData v) {
this.volt(v);
}
@Override
protected final void powder(final SnipeData v)
{
protected final void powder(final SnipeData v) {
this.data(v);
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.brushMessage("Right click with arrow to see if blocks/faces are powered. Powder measures wire current.");
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.voltmeter";
}
}

Datei anzeigen

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

Datei anzeigen

@ -11,22 +11,17 @@ import org.bukkit.block.BlockFace;
*
* @author Voxel
*/
public class VoxelDiscFaceBrush extends PerformBrush
{
public class VoxelDiscFaceBrush extends PerformBrush {
/**
*
*/
public VoxelDiscFaceBrush()
{
public VoxelDiscFaceBrush() {
this.setName("Voxel Disc Face");
}
private void disc(final SnipeData v, Block targetBlock)
{
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--)
{
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--)
{
private void disc(final SnipeData v, Block targetBlock) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); 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());
}
private void discNS(final SnipeData v, Block targetBlock)
{
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--)
{
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--)
{
private void discNS(final SnipeData v, Block targetBlock) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--) {
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());
}
private void discEW(final SnipeData v, Block targetBlock)
{
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--)
{
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); y--)
{
private void discEW(final SnipeData v, Block targetBlock) {
for (int x = v.getBrushSize(); x >= -v.getBrushSize(); x--) {
for (int y = v.getBrushSize(); y >= -v.getBrushSize(); 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());
}
private void pre(final SnipeData v, final BlockFace bf, Block targetBlock)
{
if (bf == null)
{
private void pre(final SnipeData v, final BlockFace bf, Block targetBlock) {
if (bf == null) {
return;
}
switch (bf)
{
switch (bf) {
case NORTH:
case SOUTH:
this.discNS(v, targetBlock);
@ -89,27 +75,23 @@ public class VoxelDiscFaceBrush extends PerformBrush
}
@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());
}
@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());
}
@Override
public final void info(final Message vm)
{
public final void info(final Message vm) {
vm.brushName(this.getName());
vm.size();
}
@Override
public String getPermissionNode()
{
public String getPermissionNode() {
return "voxelsniper.brush.voxeldiscface";
}
}

Datei anzeigen

@ -1,31 +1,29 @@
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.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
public class WallSider extends Brush{
private static String[] facings = new String[] { "north", "east", "south", "west", "relative to player" };
private short c;
public class WallSider extends Brush {
private static String[] facings = new String[]{"north", "east", "south", "west", "relative to player"};
private short c;
private short d;
private double e;
private boolean f;
private boolean g;
private boolean h;
public WallSider() {
this.c = 4;
this.d = 1;
this.e = 0.0;
this.setName("WallSider");
}
private void a(final SnipeData snipeData, final Block block, final boolean b) {
final double n = (snipeData.getBrushSize() + this.e) * (snipeData.getBrushSize() + this.e);
final Vector vector;
@ -37,13 +35,12 @@ public class WallSider extends Brush{
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)))));
}
else {
} else {
c = this.c;
}
int n3 = c;
if (b) {
n3 = (short)((n3 + 2) % 4);
n3 = (short) ((n3 + 2) % 4);
}
int n4 = 98;
if (n3 == 0 || n3 == 2) {
@ -52,8 +49,7 @@ public class WallSider extends Brush{
for (int i = -snipeData.getBrushSize(); i <= snipeData.getBrushSize(); ++i) {
if (n4 == 97) {
clone.setX(vector.getX() + i);
}
else {
} else {
clone.setZ(vector.getZ() + i);
}
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) {
if (n4 == 97) {
clone.setZ(vector.getZ() + ((n3 == 2) ? n5 : (-n5)));
}
else {
} else {
clone.setX(vector.getX() + ((n3 == 1) ? n5 : (-n5)));
}
final AsyncBlock block2 = this.getWorld().getBlockAt(clone.getBlockX(), clone.getBlockY(), clone.getBlockZ());
@ -73,67 +68,61 @@ public class WallSider extends Brush{
}
if (n4 == 97) {
clone.setZ(vector.getZ());
}
else {
} else {
clone.setX(vector.getX());
}
}
}
}
}
@Override
protected final void arrow(final SnipeData snipeData) {
this.a(snipeData, this.getTargetBlock(), false);
this.a(snipeData, this.getTargetBlock(), false);
}
@Override
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) {
for (int i = 1; i < array.length; ++i) {
final String lowerCase;
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");
}
else if (lowerCase.startsWith("s")) {
this.c = (short)Integer.parseInt(lowerCase.replace("s", ""));
} else if (lowerCase.startsWith("s")) {
this.c = (short) Integer.parseInt(lowerCase.replace("s", ""));
if (this.c > 4 || this.c < 0) {
this.c = 4;
}
snipeData.sendMessage(ChatColor.AQUA + "Orientation set to " + facings[this.c]);
}
else if (lowerCase.startsWith("true")) {
} else if (lowerCase.startsWith("true")) {
this.e = 0.5;
snipeData.sendMessage(ChatColor.AQUA + "True circle mode ON.");
}
else if (lowerCase.startsWith("false")) {
} else if (lowerCase.startsWith("false")) {
this.e = 0.0;
snipeData.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
}
else if (lowerCase.startsWith("air")) {
} else if (lowerCase.startsWith("air")) {
this.g = true;
snipeData.sendMessage(ChatColor.AQUA + "Including air.");
}
else if (lowerCase.startsWith("mm")) {
} else if (lowerCase.startsWith("mm")) {
this.f = true;
snipeData.sendMessage(ChatColor.AQUA + "Replacing block.");
}
}
}
@Override
public String getPermissionNode() {
return "voxelsniper.brush.wallsider";
}
@Override
public String getPermissionNode() {
return "voxelsniper.brush.wallsider";
}
@Override
public void info(Message vm) {
// TODO Auto-generated method stub
}
@Override
public void info(Message vm) {
// TODO Auto-generated method stub
}
}

Datei anzeigen

@ -35,63 +35,57 @@ import org.bukkit.entity.Player;
/**
* @author MikeMatrix
*/
public class WarpBrush extends Brush
{
public class WarpBrush extends Brush {
/**
*
*/
public WarpBrush()
{
public WarpBrush() {
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() {
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.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.block.Block;
public class PatternPerformer extends vPerformer {
private String info;
@ -32,7 +31,7 @@ public class PatternPerformer extends vPerformer {
@Override
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 {
pattern.apply(extent, bv, bv);
} catch (WorldEditException e) {

Datei anzeigen

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

Datei anzeigen

@ -4,43 +4,42 @@
*/
package com.thevoxelbox.voxelsniper.brush.perform;
import org.bukkit.ChatColor;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
/**
* @author Voxel
*/
/* The m/i/c system of naming performers: <placement-option>[replacement-option][extras]
*
*
* placement-option is mandatory and can be material(m) [for /v], ink(i) [for /vi] or combo(c) [for both]
* replacement-option is optional and can be m [for /vr], i [for /vir] or c [for both]
* extras is optional and can be update(u) [for graphical glitch], physics(p) [for no-phys] or up [for both]
*
*
* new extra: n = no undo
*
*
* The main benefit of this system is that it provides the least possible number of characters in the paramaters
* while guaranteeing that all sensible combinations will be made. Additionally, the names will be VERY consistent
*
*
* EX Old System: /b b isrcup (use /v, /vi, /vr and /vir, update graphics and no physics)
* EX New System: /b b ccup (two characters shorter, good because snipers have been complaing about keystrokes)
*
*
*/
/* This enum is getting REALLY Long, would it be possible to algorithmically generate the full performer
/* This enum is getting REALLY Long, would it be possible to algorithmically generate the full performer
* from the pieces? So if the performer name is of the for m*, you'll setTypeId whereas if it is of the
* form c* you'd setTypeIdAndPropertyId? Similarly, if the performer is of the form *p, any setTypeId's or setTypeIdAndPropertyId's
* will be set to false instead of true? The middle bits might be tougher, being of the form _m* perhaps?
* Regex to the rescue, am I right? - Giltwist
*/
public enum PerformerE
{
public enum PerformerE {
MATERIAL(pMaterial.class, "m", "material"),
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_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_long = "";
private static Map<String, vPerformer> performers;
private static Map<String, String> long_names;
PerformerE(Class<? extends vPerformer> c, String s, String l)
{
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
{
static {
performers = new TreeMap<>();
long_names = new TreeMap<>();
for (PerformerE pe : values())
{
for (PerformerE pe : values()) {
performers.put(pe.short_name, pe.getPerformer());
long_names.put(pe.long_name, pe.short_name);
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_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
*/
public class pCombo extends vPerformer
{
public class pCombo extends vPerformer {
private int i;
private int d;
public pCombo()
{
public pCombo() {
name = "Combo";
}
@Override
public void info(Message vm)
{
public void info(Message vm) {
vm.performerName(name);
vm.voxel();
vm.data();
}
@Override
public void init(com.thevoxelbox.voxelsniper.SnipeData v)
{
public void init(com.thevoxelbox.voxelsniper.SnipeData v) {
w = v.getWorld();
i = v.getVoxelId();
d = v.getPropertyId();
}
@SuppressWarnings("deprecation")
@Override
public void perform(AsyncBlock b)
{
@Override
public void perform(AsyncBlock b) {
h.put(b);
b.setTypeIdAndPropertyId(i, d, true);
}

Datei anzeigen

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

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