diff --git a/.github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md b/.github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md new file mode 100644 index 000000000..07b0f7b25 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md @@ -0,0 +1,39 @@ +--- +name: Bug / Issue report for FastAsyncWorldEdit 1.13.2 +about: Bug / Issue report about this plugin +title: '' +labels: Requires Testing +assignees: '' + +--- + +# Bug report for FastAsyncWorldEdit 1.13.2 + + + + +**[REQUIRED] FastAsyncWorldEdit Version Number:** + + +**[REQUIRED] Spigot/Paper Version Number:** + + +**Links to config.yml and config-legacy.yml file:** + + +**[REQUIRED] Description of the problem:** + + + +**Plugins being used on the server:** + + +**How to replicate**: + + +**Checklist**: + +- [] I included all information required in the sections above +- [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues?utf8=%E2%9C%93&q=is%3Aissue) +- [] I made sure I am using an up-to-date version of [FastAsyncWorldEdit for 1.13.2](https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/) +- [] I made sure the bug/error is not caused by any other plugin diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..0695e00a9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: "[+] Enhancement" +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.gitignore b/.gitignore index f632b0d1f..18c977f27 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ lib/ *.bat worldedit-bukkit/src/main/java/ignore/* todo.txt -mvn/* \ No newline at end of file +mvn/* +docs/ \ No newline at end of file diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md deleted file mode 100644 index 8c525310d..000000000 --- a/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,19 +0,0 @@ -# Bug report for FastAsyncWorldEdit 1.13.x - - - -**Debug paste link**: - - -**Description of the problem:** - - -**How to replicate**: - - -**Checklist**: - -- [] I included a `/fawe debugpaste` link -- [] I made sure there aren't duplicates of this report [(Use Search)](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues?utf8=%E2%9C%93&q=is%3Aissue) -- [] I made sure I am using an up-to-date version of [FAWE for 1.13.x](https://ci.athion.net/job/FastAsyncWorldEdit-1.13/) -- [] I made sure the bug/error is not caused by any other plugin diff --git a/README.md b/README.md index c8494060a..60ee346f6 100644 --- a/README.md +++ b/README.md @@ -11,17 +11,19 @@ FAWE is a fork of WorldEdit that has huge speed and memory improvements and cons * [Spigot Page](https://www.spigotmc.org/threads/fast-async-worldedit.100104/) * [Discord](https://discord.gg/ngZCzbU) * [Wiki](https://github.com/boy0001/FastAsyncWorldedit/wiki) -* [Report Issue](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues/new) +* [Report Issue](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues) ## Downloads ### 1.13+ -* [Download](https://incendo.org/download/) -* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-1.13/) +* [Download](https://empcraft.com/fawe/download/) +* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/) +* [JavaDoc](https://ci.athion.net/job/FastAsyncWorldEdit-1.13/javadoc/) ### < 1.12.2 -* [Download](https://incendo.org/download/) +* [Download](https://empcraft.com/fawe/download/?bukkit) * [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit/) * [Repository](https://github.com/boy0001/FastAsyncWorldedit) +* [JavaDoc](https://ci.athion.net/job/FastAsyncWorldEdit/javadoc/) ## Building diff --git a/build.gradle b/build.gradle index fae84bd06..4ac8782c2 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,6 @@ import org.ajoberstar.grgit.Grgit buildscript { repositories { - mavenLocal() mavenCentral() maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } jcenter() @@ -10,8 +9,6 @@ buildscript { configurations.all { resolutionStrategy { - force 'com.google.guava:guava:21.0' - force 'org.ow2.asm:asm:6.0_BETA' force 'commons-io:commons-io:2.4' } } @@ -27,14 +24,19 @@ plugins { id "org.ajoberstar.grgit" version "3.1.1" } -apply plugin: 'java' -clean { delete "target" } +println """ +******************************************* + You are building WorldEdit! + If you encounter trouble: + 1) Read COMPILING.md if you haven't yet + 2) Try running 'build' in a separate Gradle run + 3) Use gradlew and not gradle + 4) If you still need help, ask on Discord! https://discord.gg/ngZCzbU -def splashFile = new File('splash.txt') -if (splashFile.exists()) { - print splashFile.text -} + Output files will be in /target +******************************************* +""" group = 'com.boydti.fawe' @@ -58,42 +60,54 @@ ext { } } -if ( project.hasProperty("lzNoVersion") ) { // gradle build -PlzNoVersion - version = "unknown" -} else { - version = String.format("%s.%s", rootVersion, buildNumber) -} +version = String.format("%s.%s", rootVersion, buildNumber) + description = rootProject.name subprojects { + repositories { + mavenCentral() + maven { url "http://maven.sk89q.com/repo/" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "http://repo.maven.apache.org/maven2" } + // Fawe + maven { url "https://mvnrepository.com/artifact/" } + maven { url "http://repo.dmulloy2.net/content/groups/public/" } + maven { url "https://repo.destroystokyo.com/repository/maven-public//" } + maven { url "http://ci.athion.net/job/PlotSquared-Breaking/ws/mvn/" } + maven { url "https://libraries.minecraft.net" } + mavenLocal() + maven { url "http://empcraft.com/maven2" } + maven { url "https://hub.spigotmc.org/nexus/content/groups/public/" } + maven { url "http://ci.frostcast.net/plugin/repository/everything" } + maven { url "http://maven.sk89q.com/artifactory/repo" } + maven { url "http://repo.spongepowered.org/maven" } + maven { url "http://dl.bintray.com/tastybento/maven-repo" } + maven { url "http://ci.emc.gs/nexus/content/groups/aikar/" } + } + configurations.all { + resolutionStrategy { + cacheChangingModulesFor 5, 'minutes' + } + } +} + +configure(['worldedit-core', 'worldedit-bukkit', 'favs'].collect { project("$it") }) { apply plugin: 'java' apply plugin: 'maven' +// apply plugin: 'checkstyle' apply plugin: 'com.github.johnrengelman.shadow' - // Enable this requires putting license header files in many, many FAWE files - //apply plugin: 'net.minecrell.licenser' +// Enable this requires putting license header files in many, many FAWE files +// apply plugin: 'net.minecrell.licenser' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 - compileJava { options.compilerArgs += ["-parameters"] } +// checkstyle.configFile = new File(rootProject.projectDir, "config/checkstyle/checkstyle.xml") +// checkstyle.toolVersion = '7.6.1' - repositories { - mavenCentral() - maven { url "http://maven.sk89q.com/repo/" } - maven { url "http://repo.maven.apache.org/maven2" } - // Fawe - maven {url "https://mvnrepository.com/artifact/"} - maven {url "http://repo.dmulloy2.net/content/groups/public/"} - maven {url "https://repo.destroystokyo.com/repository/maven-public//"} - maven {url "http://ci.athion.net/job/PlotSquared-Breaking/ws/mvn/"} - mavenLocal() - maven {url "http://empcraft.com/maven2"} - maven {url "https://hub.spigotmc.org/nexus/content/groups/public/"} - maven {url "http://ci.frostcast.net/plugin/repository/everything"} - maven {url "http://maven.sk89q.com/artifactory/repo"} - maven {url "http://repo.spongepowered.org/maven"} - maven {url "http://dl.bintray.com/tastybento/maven-repo"} - maven {url "http://ci.emc.gs/nexus/content/groups/aikar/" } + clean.doFirst { + delete "../target" } if (JavaVersion.current().isJava8Compatible()) { @@ -103,16 +117,6 @@ subprojects { } } - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } - - artifacts { - archives jar - archives javadocJar - } - if (!(name.equals('worldedit-forge') || name.equals('worldedit-sponge'))) { task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' @@ -125,23 +129,52 @@ subprojects { build.dependsOn(sourcesJar) } - shadowJar { - classifier 'dist' - dependencies { - include(dependency('com.sk89q:jchronic:0.2.4a')) - include(dependency('com.thoughtworks.paranamer:paranamer:2.6')) - include(dependency('com.sk89q.lib:jlibnoise:1.0.0')) - include(dependency('com.github.luben:zstd-jni:1.1.1')) - include(dependency('co.aikar:fastutil-lite:1.0')) - } - exclude 'GradleStart**' - exclude '.cache' - exclude 'LICENSE*' +// build.dependsOn(checkstyleMain) +// build.dependsOn(checkstyleTest) + + dependencies { + compileOnly 'org.jetbrains:annotations:17.0.0' } - // Enable this requires putting license header files in many, many FAWE files - //license { - // header = rootProject.file("HEADER.txt") - // include '**/*.java' - //} + configure(['bukkit'].collect { project(":worldedit-$it") }) { + shadowJar { + classifier 'dist' + dependencies { + include(project(":worldedit-libs:core")) + include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}")) + include(project(":worldedit-core")) + include(dependency('com.github.luben:zstd-jni:1.1.1')) + include(dependency('co.aikar:fastutil-lite:1.0')) + } + exclude 'GradleStart**' + exclude '.cache' + exclude 'LICENSE*' + } + + // Enable this requires putting license header files in many, many FAWE files + //license { + // header = rootProject.file("HEADER.txt") + // include '**/*.java' + //} + } + task aggregatedJavadocs(type: Javadoc, description: 'Generate javadocs from all child projects as if it was a single project', group: 'Documentation') { + destinationDir = file("./docs/javadoc") + title = "$project.name $version API" + options.author true + options.links 'http://docs.spring.io/spring/docs/4.3.x/javadoc-api/', 'http://docs.oracle.com/javase/8/docs/api/', 'http://docs.spring.io/spring-ws/docs/2.3.0.RELEASE/api/', 'http://docs.spring.io/spring-security/site/docs/4.0.4.RELEASE/apidocs/' + options.addStringOption('Xdoclint:none', '-quiet') + + delete "./docs" + + subprojects.each { proj -> + proj.tasks.withType(Javadoc).each { javadocTask -> + source += javadocTask.source + classpath += javadocTask.classpath + excludes += javadocTask.excludes + includes += javadocTask.includes + } + } + } + + } diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index a2d043d73..89177a84c 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -53,5 +53,19 @@ + + + + + + + + + + + + + + diff --git a/config/checkstyle/import-control.xml b/config/checkstyle/import-control.xml index 28ccad1e4..a291b5ad5 100644 --- a/config/checkstyle/import-control.xml +++ b/config/checkstyle/import-control.xml @@ -16,6 +16,7 @@ + @@ -38,11 +39,12 @@ + - + @@ -55,6 +57,7 @@ + diff --git a/favs/src/main/java/com/boydti/fawe/bukkit/favs/PatternUtil.java b/favs/src/main/java/com/boydti/fawe/bukkit/favs/PatternUtil.java index 81d4e6f9f..c4c9c6172 100644 --- a/favs/src/main/java/com/boydti/fawe/bukkit/favs/PatternUtil.java +++ b/favs/src/main/java/com/boydti/fawe/bukkit/favs/PatternUtil.java @@ -1,6 +1,5 @@ package com.boydti.fawe.bukkit.favs; -import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.FawePlayer; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; @@ -23,7 +22,7 @@ public class PatternUtil { snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + arg); return pattern; } catch (InputParseException e) { - fp.sendMessage(BBC.getPrefix() + e.getMessage()); + fp.sendMessage(e.getMessage()); return null; } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java index 211103c80..6fac69b6b 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java @@ -3,9 +3,6 @@ package com.thevoxelbox.voxelsniper; import com.sk89q.worldedit.world.block.BlockTypes; import org.bukkit.ChatColor; -/** - * - */ public class Message { private static final int BRUSH_SIZE_WARNING_THRESHOLD = 20; private final SnipeData snipeData; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java index d20ee7e8d..94eb54c57 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java @@ -23,9 +23,9 @@ public final class 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 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") diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java index f4cfc718f..26778a69c 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java @@ -1,4 +1,4 @@ -/** +/* This file is part of VoxelSniper, licensed under the MIT License (MIT). Copyright (c) The VoxelBox @@ -281,8 +281,8 @@ public class RangeBlockHelper { this.range = range; this.step = step; this.length = 0.0D; - this.rotX = (double)((this.playerLoc.getYaw() + 90.0F) % 360.0F); - this.rotY = (double)(this.playerLoc.getPitch() * -1.0F); + this.rotX = (this.playerLoc.getYaw() + 90.0F) % 360.0F; + this.rotY = this.playerLoc.getPitch() * -1.0F; this.rotYCos = Math.cos(Math.toRadians(this.rotY)); this.rotYSin = Math.sin(Math.toRadians(this.rotY)); this.rotXCos = Math.cos(Math.toRadians(this.rotX)); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java index 9362ec448..1a11e4221 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java @@ -1,8 +1,5 @@ package com.thevoxelbox.voxelsniper; -/** - * - */ public enum SnipeAction { ARROW, GUNPOWDER } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeData.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeData.java index 0c7bbe9e9..ef4d2e9ba 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeData.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeData.java @@ -1,4 +1,4 @@ -/** +/* This file is part of VoxelSniper, licensed under the MIT License (MIT). Copyright (c) The VoxelBox @@ -33,9 +33,6 @@ import org.bukkit.ChatColor; import org.bukkit.World; import org.bukkit.entity.Player; -/** - * @author Piotr - */ public class SnipeData { public static final int DEFAULT_REPLACE_DATA_VALUE = 0; @@ -87,9 +84,6 @@ public class SnipeData { private Pattern pattern; private String patternInfo; - /** - * @param vs - */ public SnipeData(final Sniper vs) { this.owner = vs; } @@ -219,9 +213,6 @@ public class SnipeData { this.voxelList = new VoxelList(); } - /** - * @param message - */ public final void sendMessage(final String message) { this.owner.getPlayer().sendMessage(message); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java index 35c52cf11..a024f7d23 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java @@ -1,4 +1,4 @@ -/** +/* This file is part of VoxelSniper, licensed under the MIT License (MIT). Copyright (c) The VoxelBox @@ -71,7 +71,6 @@ import java.util.Map; import java.util.UUID; public class Sniper { - private VoxelSniper plugin; private final UUID player; private boolean enabled = true; // private LinkedList undoList = new LinkedList<>(); @@ -80,7 +79,6 @@ public class Sniper { public Sniper(VoxelSniper plugin, Player player) { Preconditions.checkNotNull(plugin); Preconditions.checkNotNull(player); - this.plugin = plugin; this.player = player.getUniqueId(); SniperTool sniperTool = new SniperTool(this); sniperTool.assignAction(SnipeAction.ARROW, Material.ARROW); @@ -89,7 +87,7 @@ public class Sniper { } public String getCurrentToolId() { - return getToolId((getPlayer().getInventory().getItemInMainHand() != null) ? getPlayer().getInventory().getItemInMainHand().getType() : null); + return getToolId(getPlayer().getInventory().getItemInMainHand().getType()); } public String getToolId(Material itemInHand) { @@ -130,10 +128,10 @@ public class Sniper { /** * Sniper execution call. * - * @param action Action player performed - * @param itemInHand Item in hand of player + * @param action Action player performed + * @param itemInHand Item in hand of player * @param clickedBlock Block that the player targeted/interacted with - * @param clickedFace Face of that targeted Block + * @param clickedFace Face of that targeted Block * @return true if command visibly processed, false otherwise. */ public boolean snipe(final Action action, final Material itemInHand, final Block clickedBlock, final BlockFace clickedFace) { @@ -397,14 +395,12 @@ public class Sniper { } else { changeQueue.flush(); } - if (changeSet != null) { - if (Settings.IMP.HISTORY.COMBINE_STAGES) { - changeSet.closeAsync(); - } else { - changeSet.close(); - } - session.remember(changeSet.toEditSession(fp)); + if (Settings.IMP.HISTORY.COMBINE_STAGES) { + changeSet.closeAsync(); + } else { + changeSet.close(); } + session.remember(changeSet.toEditSession(fp)); return true; } return false; @@ -511,7 +507,7 @@ public class Sniper { count++; } if (count > 0) { - BBC.COMMAND_UNDO_SUCCESS.send(fp); + BBC.COMMAND_UNDO_SUCCESS.send(fp, count == 1 ? "" : " x" + count); } else { BBC.COMMAND_UNDO_ERROR.send(fp); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java index e71d9ad26..2ba2a3b4c 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java @@ -6,9 +6,6 @@ import org.bukkit.entity.Player; import java.util.Map; import java.util.UUID; -/** - * - */ public class SniperManager { private Map sniperInstances = Maps.newHashMap(); private VoxelSniper plugin; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Undo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Undo.java index a999f7bf4..7f6f7a2f4 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Undo.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/Undo.java @@ -1,4 +1,4 @@ -/** +/* This file is part of VoxelSniper, licensed under the MIT License (MIT). Copyright (c) The VoxelBox diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java index 9072ef36c..1af02afad 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java @@ -1,5 +1,6 @@ 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; @@ -8,7 +9,16 @@ import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; /** * Bukkit extension point. @@ -54,16 +64,46 @@ public class VoxelSniper extends JavaPlugin { return sniperManager; } - @Override - public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { + private static Map lookupNames; + static { + { // Disable BetterBrushes - FAVS includes the features and BetterBrushes is outdated + PluginManager manager = Bukkit.getPluginManager(); + try { + Field pluginsField = manager.getClass().getDeclaredField("plugins"); + Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames"); + pluginsField.setAccessible(true); + lookupNamesField.setAccessible(true); + List plugins = (List) pluginsField.get(manager); + lookupNames = (Map) lookupNamesField.get(manager); + pluginsField.set(manager, new ArrayList(plugins) { + @Override + public boolean add(Plugin plugin) { + if (plugin.getName().startsWith("BetterBrushes")) { + Fawe.debug("Disabling `" + plugin.getName() + "`. FastAsyncVoxelSniper includes all the features."); + } else { + return super.add(plugin); + } + return false; + } + }); + lookupNamesField.set(manager, lookupNames = new ConcurrentHashMap(lookupNames) { + @Override + public Plugin put(@NotNull String key, @NotNull Plugin plugin) { + if (plugin.getName().startsWith("BetterBrushes")) { + return null; + } + return super.put(key, plugin); + } + }); + } catch (Throwable ignore) {} + } + } + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, String commandLabel, @NotNull String[] args) { if (sender instanceof Player) { - String[] arguments = args; - if (arguments == null) { - arguments = new String[0]; - } - - return voxelSniperListener.onCommand((Player) sender, arguments, command.getName()); + return voxelSniperListener.onCommand((Player) sender, args, command.getName()); } getLogger().info("Only players can execute VoxelSniper commands."); @@ -90,7 +130,7 @@ public class VoxelSniper extends JavaPlugin { Player player = (Player) fp.parent; return onCommand(player, new Command("p") { @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { + public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) { return false; } }, null, args); @@ -103,7 +143,7 @@ public class VoxelSniper extends JavaPlugin { Player player = (Player) fp.parent; return onCommand(player, new Command("d") { @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { + public boolean execute(@NotNull CommandSender sender, String commandLabel, @NotNull String[] args) { return false; } }, null, args); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java index 0e2e28aac..1e1b58e63 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java @@ -1,20 +1,14 @@ package com.thevoxelbox.voxelsniper; -import com.google.common.base.Preconditions; import org.bukkit.configuration.file.FileConfiguration; -import java.util.List; - /** * Configuration storage defining global configurations for VoxelSniper. */ 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"; public static final String CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED = "message-on-login-enabled"; - public static final int DEFAULT_LITESNIPER_MAX_BRUSH_SIZE = 5; - public static final int DEFAULT_UNDO_CACHE_SIZE = 20; + public static final int DEFAULT_LITESNIPER_MAX_BRUSH_SIZE = 30; public static final boolean DEFAULT_MESSAGE_ON_LOGIN_ENABLED = true; private FileConfiguration configuration; @@ -25,24 +19,6 @@ public class VoxelSniperConfiguration { this.configuration = configuration; } - /** - * Returns the maximum amount of snipes stored in the undo cache of snipers. - * - * @return the maximum amount of snipes stored in the undo cache of snipers - */ - public int getUndoCacheSize() { - return configuration.getInt(CONFIG_IDENTIFIER_UNDO_CACHE_SIZE, DEFAULT_UNDO_CACHE_SIZE); - } - - /** - * Set the maximum amount of snipes stored in the undo cache of snipers. - * - * @param size size of undo cache - */ - public void setUndoCacheSize(int size) { - configuration.set(CONFIG_IDENTIFIER_UNDO_CACHE_SIZE, size); - } - /** * Returns maximum size of brushes that LiteSnipers can use. * @@ -52,34 +28,6 @@ public class VoxelSniperConfiguration { return configuration.getInt(CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE, DEFAULT_LITESNIPER_MAX_BRUSH_SIZE); } - /** - * Set maximum size of brushes that LiteSnipers can use. - * - * @param size maximum size - */ - public void setLiteSniperMaxBrushSize(int size) { - configuration.set(CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE, size); - } - - /** - * Returns List of restricted Litesniper Items. - * - * @return List of restricted Litesniper Items - */ - public List getLiteSniperRestrictedItems() { - return configuration.getIntegerList(CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS); - } - - /** - * Set new list of restricted Litesniper Items. - * - * @param restrictedItems List of restricted Litesniper Items - */ - public void setLitesniperRestrictedItems(List restrictedItems) { - Preconditions.checkNotNull(restrictedItems, "Restricted items must be a list."); - configuration.set(CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS, restrictedItems); - } - /** * Returns if the login message is enabled. * @@ -88,13 +36,4 @@ public class VoxelSniperConfiguration { public boolean isMessageOnLoginEnabled() { return configuration.getBoolean(CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED, DEFAULT_MESSAGE_ON_LOGIN_ENABLED); } - - /** - * Set the message on login to be enabled or disabled. - * - * @param enabled Message on Login enabled - */ - public void setMessageOnLoginEnabled(boolean enabled) { - configuration.set(CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED, enabled); - } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java index ac8dc7eb7..1d0eae2d9 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java @@ -17,9 +17,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import java.util.HashMap; import java.util.Map; -/** - * @author Voxel - */ + public class VoxelSniperListener implements Listener { private static final String SNIPER_PERMISSION = "voxelsniper.sniper"; @@ -117,9 +115,6 @@ public class VoxelSniperListener implements Listener { } } - /** - * @param event - */ @EventHandler(ignoreCancelled = false) public final void onPlayerInteract(final PlayerInteractEvent event) { Player player = event.getPlayer(); @@ -133,14 +128,11 @@ public class VoxelSniperListener implements Listener { if (sniper.isEnabled() && sniper.snipe(event.getAction(), event.getMaterial(), event.getClickedBlock(), event.getBlockFace())) { event.setCancelled(true); } - } catch (final Throwable ignored) { - ignored.printStackTrace(); + } catch (final Throwable throwable) { + throwable.printStackTrace(); } } - /** - * @param event - */ @EventHandler public final void onPlayerJoin(final PlayerJoinEvent event) { Player player = event.getPlayer(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BallBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BallBrush.java index 3fbd56d7b..ab0be7e1f 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BallBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BallBrush.java @@ -8,7 +8,6 @@ import org.bukkit.ChatColor; /** * A brush that creates a solid ball. - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Ball_Brush * * @author Piotr */ @@ -17,10 +16,7 @@ public class BallBrush extends PerformBrush { public static final int TRUE_CIRCLE_OFF_VALUE = 0; private double trueCircle = 0; - /** - * - */ - public BallBrush() { +public BallBrush() { this.setName("Ball"); } @@ -111,7 +107,7 @@ public class BallBrush extends PerformBrush { this.trueCircle = TRUE_CIRCLE_OFF_VALUE; v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BiomeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BiomeBrush.java index ac7b22948..4fe7eaedf 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BiomeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BiomeBrush.java @@ -6,15 +6,10 @@ import org.bukkit.ChatColor; import org.bukkit.block.Biome; import org.bukkit.block.Block; -/** - * - */ public class BiomeBrush extends Brush { + private Biome selectedBiome = Biome.PLAINS; - /** - * - */ public BiomeBrush() { this.setName("Biome (/b biome [Biome Name])"); } @@ -78,7 +73,7 @@ public class BiomeBrush extends Brush { } availableBiomes.append(ChatColor.RED + ", " + ChatColor.DARK_GREEN) - .append(biome.name()); + .append(biome.name()); } v.sendMessage(ChatColor.DARK_BLUE + "Available biomes: " + availableBiomes); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java index 25eda42c1..76f4a0bc6 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java @@ -6,13 +6,8 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Undo; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes - */ public class BlendBallBrush extends BlendBrushBase { - /** - * - */ + public BlendBallBrush() { this.setName("Blend Ball"); } @@ -40,7 +35,7 @@ public class BlendBallBrush extends BlendBrushBase { 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); } } @@ -90,7 +85,7 @@ public class BlendBallBrush extends BlendBrushBase { final Undo undo = new Undo(); final double rSquared = Math.pow(brushSize + 1, 2); - // Make the changes + // Make the changes for (int x = brushSizeDoubled; x >= 0; x--) { final double xSquared = Math.pow(x - brushSize - 1, 2); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBrushBase.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBrushBase.java index eccd8caac..b0c0a0fa8 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBrushBase.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBrushBase.java @@ -4,17 +4,10 @@ import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; import org.bukkit.ChatColor; -/** - * @author Monofraps - */ -@SuppressWarnings("deprecation") public abstract class BlendBrushBase extends Brush { protected boolean excludeAir = true; protected boolean excludeWater = true; - /** - * @param v - */ protected abstract void blend(final SnipeData v); @Override @@ -47,30 +40,18 @@ public abstract class BlendBrushBase extends Brush { } } - /** - * @return - */ protected final boolean isExcludeAir() { return excludeAir; } - /** - * @param excludeAir - */ protected final void setExcludeAir(boolean excludeAir) { this.excludeAir = excludeAir; } - /** - * @return - */ protected final boolean isExcludeWater() { return excludeWater; } - /** - * @param excludeWater - */ protected final void setExcludeWater(boolean excludeWater) { this.excludeWater = excludeWater; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java index 9601fa78c..2c50ac304 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java @@ -6,13 +6,8 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Undo; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes - */ public class BlendDiscBrush extends BlendBrushBase { - /** - * - */ + public BlendDiscBrush() { this.setName("Blend Disc"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java index 31e34495f..89f5946bd 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java @@ -6,13 +6,8 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Undo; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes - */ public class BlendVoxelBrush extends BlendBrushBase { - /** - * - */ + public BlendVoxelBrush() { this.setName("Blend Voxel"); } @@ -40,7 +35,7 @@ public class BlendVoxelBrush extends BlendBrushBase { 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); } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java index 4721b3d9b..eb6d17de1 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java @@ -6,13 +6,8 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Undo; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Blend_Brushes - */ public class BlendVoxelDiscBrush extends BlendBrushBase { - /** - * - */ + public BlendVoxelDiscBrush() { this.setName("Blend Voxel Disc"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlobBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlobBrush.java index 90390ff15..7b6a3675d 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlobBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlobBrush.java @@ -7,11 +7,6 @@ import org.bukkit.ChatColor; import java.util.Random; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Blob_Brush - * - * @author Giltwist - */ public class BlobBrush extends PerformBrush { private static final int GROW_PERCENT_DEFAULT = 1000; private static final int GROW_PERCENT_MIN = 1; @@ -20,9 +15,6 @@ public class BlobBrush extends PerformBrush { private Random randomGenerator = new Random(); private int growPercent = GROW_PERCENT_DEFAULT; // chance block on recursion pass is made active - /** - * - */ public BlobBrush() { this.setName("Blob"); } @@ -101,7 +93,7 @@ public class BlobBrush extends PerformBrush { final double rSquared = Math.pow(brushSize + 1, 2); - // Make the changes + // Make the changes for (int x = brushSizeDoubled; x >= 0; x--) { final double xSquared = Math.pow(x - brushSize - 1, 2); @@ -233,7 +225,7 @@ public class BlobBrush extends PerformBrush { v.sendMessage(ChatColor.RED + "Growth percent must be an integer " + GROW_PERCENT_MIN + "-" + GROW_PERCENT_MAX + "!"); } } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetBrush.java index ff2aca000..f2383e69c 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetBrush.java @@ -7,39 +7,36 @@ import org.bukkit.block.Block; import java.util.ArrayList; -/** - * @author MikeMatrix - */ public class BlockResetBrush extends Brush { private static final ArrayList DENIED_UPDATES = new ArrayList<>(); static { BlockResetBrush.DENIED_UPDATES.add(Material.SIGN); - BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_SIGN_POST); BlockResetBrush.DENIED_UPDATES.add(Material.WALL_SIGN); BlockResetBrush.DENIED_UPDATES.add(Material.CHEST); BlockResetBrush.DENIED_UPDATES.add(Material.FURNACE); - BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_BURNING_FURNACE); - BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_REDSTONE_TORCH_OFF); - BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_REDSTONE_TORCH_ON); + BlockResetBrush.DENIED_UPDATES.add(Material.REDSTONE_TORCH); + BlockResetBrush.DENIED_UPDATES.add(Material.REDSTONE_WALL_TORCH); BlockResetBrush.DENIED_UPDATES.add(Material.REDSTONE_WIRE); - BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_DIODE_BLOCK_OFF); - BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_DIODE_BLOCK_ON); - BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_WOODEN_DOOR); - BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_WOOD_DOOR); + BlockResetBrush.DENIED_UPDATES.add(Material.OAK_DOOR); + BlockResetBrush.DENIED_UPDATES.add(Material.DARK_OAK_DOOR); + BlockResetBrush.DENIED_UPDATES.add(Material.BIRCH_DOOR); + BlockResetBrush.DENIED_UPDATES.add(Material.ACACIA_DOOR); + BlockResetBrush.DENIED_UPDATES.add(Material.SPRUCE_DOOR); + BlockResetBrush.DENIED_UPDATES.add(Material.JUNGLE_DOOR); BlockResetBrush.DENIED_UPDATES.add(Material.IRON_DOOR); - BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_IRON_DOOR_BLOCK); - BlockResetBrush.DENIED_UPDATES.add(Material.LEGACY_FENCE_GATE); + BlockResetBrush.DENIED_UPDATES.add(Material.DARK_OAK_FENCE_GATE); + BlockResetBrush.DENIED_UPDATES.add(Material.ACACIA_FENCE_GATE); + BlockResetBrush.DENIED_UPDATES.add(Material.BIRCH_FENCE_GATE); + BlockResetBrush.DENIED_UPDATES.add(Material.SPRUCE_FENCE_GATE); + BlockResetBrush.DENIED_UPDATES.add(Material.JUNGLE_FENCE_GATE); + BlockResetBrush.DENIED_UPDATES.add(Material.OAK_FENCE_GATE); } - /** - * - */ 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++) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java index c2cc62ef0..c08e7e345 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java @@ -24,14 +24,11 @@ import org.bukkit.Material; * @author GavJenks */ public class BlockResetSurfaceBrush extends Brush { - /** - * - */ + public BlockResetSurfaceBrush() { this.setName("Block Reset Brush Surface Only"); } - @SuppressWarnings("deprecation") private void applyBrush(final SnipeData v) { final AsyncWorld world = this.getWorld(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Brush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Brush.java index 904794ecf..abe48d61f 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Brush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Brush.java @@ -33,9 +33,9 @@ public abstract class Brush implements IBrush { private String name = "Undefined"; /** - * @param x - * @param y - * @param z + * @param x X coordinate + * @param y Y coordinate + * @param z Z coordinate * @return {@link Block} */ public final AsyncBlock clampY(final int x, final int y, final int z) { @@ -103,9 +103,9 @@ public abstract class Brush implements IBrush { /** * Overridable getTarget method. * - * @param v - * @param clickedBlock - * @param clickedFace + * @param v Sniper caller + * @param clickedBlock Block that the player targeted/interacted with + * @param clickedFace Face of that targeted Block * @return boolean */ protected final boolean getTarget(final SnipeData v, final AsyncBlock clickedBlock, final BlockFace clickedFace) { @@ -123,7 +123,7 @@ public abstract class Brush implements IBrush { } else { RangeBlockHelper rangeBlockHelper; if (v.owner().getSnipeData(v.owner().getCurrentToolId()).isRanged()) { - rangeBlockHelper = new RangeBlockHelper(v.owner().getPlayer(), v.owner().getWorld(), (double) v.owner().getSnipeData(v.owner().getCurrentToolId()).getRange()); + rangeBlockHelper = new RangeBlockHelper(v.owner().getPlayer(), v.owner().getWorld(), v.owner().getSnipeData(v.owner().getCurrentToolId()).getRange()); this.setTargetBlock(rangeBlockHelper.getRangeBlock()); } else { rangeBlockHelper = new RangeBlockHelper(v.owner().getPlayer(), v.owner().getWorld()); @@ -190,7 +190,6 @@ public abstract class Brush implements IBrush { * @param z Z coordinate * @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) { return getWorld().getBlockAt(x, y, z).getTypeId(); } @@ -243,9 +242,9 @@ public abstract class Brush implements IBrush { /** * Sets the Id of the block at the passed coordinate. * - * @param z Z coordinate - * @param x X coordinate - * @param y Y coordinate + * @param z Z coordinate + * @param x X coordinate + * @param y Y coordinate * @param id The id the block will be set to */ @SuppressWarnings("deprecation") @@ -256,10 +255,10 @@ public abstract class Brush implements IBrush { /** * Sets the id and data value of the block at the passed coordinate. * - * @param x X coordinate - * @param y Y coordinate - * @param z Z coordinate - * @param id The id the block will be set to + * @param x X coordinate + * @param y Y coordinate + * @param z Z coordinate + * @param id The id the block will be set to * @param data The data value the block will be set to */ @SuppressWarnings("deprecation") @@ -270,10 +269,10 @@ public abstract class Brush implements IBrush { /** * Sets the id and data value of the block at the passed coordinate. * - * @param x X coordinate - * @param y Y coordinate - * @param z Z coordinate - * @param id The id the block will be set to + * @param x X coordinate + * @param y Y coordinate + * @param z Z coordinate + * @param id The id the block will be set to * @param data The data value the block will be set to */ @SuppressWarnings("deprecation") diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonBrush.java index 4be9a18ea..d075d7225 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonBrush.java @@ -11,27 +11,16 @@ import org.bukkit.Chunk; import org.bukkit.Material; import org.bukkit.block.Block; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_CANYONATOR - * - * @author Voxel - */ + 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; - /** - * - */ public CanyonBrush() { this.setName("Canyon"); } - /** - * @param chunk - * @param undo - */ @SuppressWarnings("deprecation") protected final void canyon(final AsyncChunk chunk, final Undo undo) { for (int x = 0; x < CHUNK_SIZE; x++) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonSelectionBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonSelectionBrush.java index 9d3f96dfb..7b2183fbe 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonSelectionBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CanyonSelectionBrush.java @@ -6,19 +6,12 @@ import com.thevoxelbox.voxelsniper.Undo; import org.bukkit.ChatColor; import org.bukkit.Chunk; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Canyon_Selection_Brush - * - * @author Voxel - */ + public class CanyonSelectionBrush extends CanyonBrush { private boolean first = true; private int fx; private int fz; - /** - * - */ public CanyonSelectionBrush() { this.setName("Canyon Selection"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CheckerVoxelDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CheckerVoxelDiscBrush.java index 976327cce..50db6161d 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CheckerVoxelDiscBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CheckerVoxelDiscBrush.java @@ -6,9 +6,6 @@ import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; import org.bukkit.block.Block; -/** - * @author MikeMatrix - */ public class CheckerVoxelDiscBrush extends PerformBrush { private boolean useWorldCoordinates = true; @@ -19,10 +16,6 @@ public class CheckerVoxelDiscBrush extends PerformBrush { this.setName("Checker Voxel Disc"); } - /** - * @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--) { @@ -69,7 +62,7 @@ public class CheckerVoxelDiscBrush extends PerformBrush { this.useWorldCoordinates = false; v.sendMessage(ChatColor.AQUA + "Disabled using World Coordinates."); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); break; } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CleanSnowBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CleanSnowBrush.java index 58e6271a2..69a012c4c 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CleanSnowBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CleanSnowBrush.java @@ -7,17 +7,9 @@ import com.thevoxelbox.voxelsniper.Undo; import org.bukkit.ChatColor; import org.bukkit.Material; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Clean_Snow_Brush - * - * @author psanker - */ public class CleanSnowBrush extends Brush { private double trueCircle = 0; - /** - * - */ public CleanSnowBrush() { this.setName("Clean Snow"); } @@ -80,7 +72,7 @@ public class CleanSnowBrush extends Brush { this.trueCircle = 0; v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java index 79793af7d..189c0cbfc 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java @@ -6,15 +6,11 @@ import org.bukkit.ChatColor; /** * The CloneStamp class is used to create a collection of blocks in a cylinder shape according to the selection the player has set. - * http://www.voxelwiki.com/minecraft/Voxelsniper#Clone_and_CopyPasta_Brushes * * @author Voxel */ public class CloneStampBrush extends StampBrush { - /** - * - */ - public CloneStampBrush() { +public CloneStampBrush() { this.setName("Clone"); } @@ -24,7 +20,7 @@ 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 Sniper Caller */ private void clone(final SnipeData v) { final int brushSize = v.getBrushSize(); @@ -109,7 +105,7 @@ 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 SnipeData v) { final String parameter = par[1]; if (parameter.equalsIgnoreCase("info")) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CometBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CometBrush.java index ca5c55956..4e1780fe8 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CometBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CometBrush.java @@ -8,17 +8,9 @@ import org.bukkit.entity.LargeFireball; import org.bukkit.entity.SmallFireball; import org.bukkit.util.Vector; -/** - * @author Gavjenks Heavily revamped from ruler brush blockPositionY - * @author Giltwist - * @author Monofraps (Merged Meteor brush) - */ public class CometBrush extends Brush { private boolean useBigBalls = false; - /** - * - */ public CometBrush() { this.setName("Comet"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CopyPastaBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CopyPastaBrush.java index 445b99eae..9b75d324e 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CopyPastaBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CopyPastaBrush.java @@ -7,11 +7,6 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Undo; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#CopyPasta_Brush - * - * @author giltwist - */ public class CopyPastaBrush extends Brush { private static final int BLOCK_LIMIT = 10000; @@ -25,16 +20,12 @@ public class CopyPastaBrush extends Brush { private int[] offsetPoint = new int[3]; private int[] blockArray; private int[] arraySize = new int[3]; - private int pivot = 0; // ccw degrees + private int pivot = 0; // ccw degrees - /** - * - */ public CopyPastaBrush() { this.setName("CopyPasta"); } - @SuppressWarnings("deprecation") 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; @@ -103,7 +94,7 @@ public class CopyPastaBrush extends Brush { } @Override - protected final void arrow(final com.thevoxelbox.voxelsniper.SnipeData v) { + protected final void arrow(final SnipeData v) { switch (this.points) { case 0: this.firstPoint[0] = this.getTargetBlock().getX(); @@ -131,7 +122,7 @@ public class CopyPastaBrush extends Brush { } @Override - protected final void powder(final com.thevoxelbox.voxelsniper.SnipeData v) { + protected final void powder(final SnipeData v) { if (this.points == 2) { if (this.numBlocks == 0) { this.doCopy(v); @@ -156,7 +147,7 @@ public class CopyPastaBrush extends Brush { } @Override - public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) { + public final void parameters(final String[] par, final SnipeData v) { final String parameter = par[1]; if (parameter.equalsIgnoreCase("info")) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CylinderBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CylinderBrush.java index 0e458e303..7aedbaeaa 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CylinderBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CylinderBrush.java @@ -6,15 +6,9 @@ import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; import org.bukkit.block.Block; -/** - * @author Kavutop - */ public class CylinderBrush extends PerformBrush { private double trueCircle = 0; - /** - * - */ public CylinderBrush() { this.setName("Cylinder"); } @@ -104,7 +98,7 @@ public class CylinderBrush extends PerformBrush { v.setcCen((int) Double.parseDouble(parameter.replace("c", ""))); v.sendMessage(ChatColor.AQUA + "Cylinder origin set to: " + v.getcCen()); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscBrush.java index 671818fd1..907af9b75 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscBrush.java @@ -7,11 +7,6 @@ import org.bukkit.ChatColor; import org.bukkit.block.Block; import org.bukkit.util.Vector; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Disc_Brush - * - * @author Voxel - */ public class DiscBrush extends PerformBrush { private double trueCircle = 0; @@ -25,7 +20,7 @@ public class DiscBrush extends PerformBrush { /** * Disc executor. * - * @param v + * @param v Snipe Data */ private void disc(final SnipeData v, final Block targetBlock) { final double radiusSquared = (v.getBrushSize() + this.trueCircle) * (v.getBrushSize() + this.trueCircle); @@ -76,7 +71,7 @@ public class DiscBrush extends PerformBrush { this.trueCircle = 0; v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscFaceBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscFaceBrush.java index cd42fcf97..fd79fda34 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscFaceBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DiscFaceBrush.java @@ -7,17 +7,9 @@ import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; import org.bukkit.block.BlockFace; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Disc_Face_Brush - * - * @author Voxel - */ public class DiscFaceBrush extends PerformBrush { private double trueCircle = 0; - /** - * - */ public DiscFaceBrush() { this.setName("Disc Face"); } @@ -139,7 +131,7 @@ public class DiscFaceBrush extends PerformBrush { this.trueCircle = 0; v.sendMessage(ChatColor.AQUA + "True circle mode OFF."); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DomeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DomeBrush.java index f9895de90..8ab6d0480 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DomeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DomeBrush.java @@ -11,16 +11,8 @@ 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 DomeBrush() { this.setName("Dome"); } @@ -34,8 +26,8 @@ public class DomeBrush extends Brush { } /** - * @param v - * @param targetBlock + * @param v Snipe Data + * @param targetBlock the targetBlock to set */ @SuppressWarnings("deprecation") private void generateDome(final SnipeData v, final Block targetBlock) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DrainBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DrainBrush.java index 088a63ca0..80f0fcd2e 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DrainBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/DrainBrush.java @@ -6,24 +6,14 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Undo; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Drain_Brush - * - * @author Gavjenks - * @author psanker - */ public class DrainBrush extends Brush { private double trueCircle = 0; private boolean disc = false; - /** - * - */ public DrainBrush() { this.setName("Drain"); } - @SuppressWarnings("deprecation") private void drain(final SnipeData v) { final int brushSize = v.getBrushSize(); final double brushSizeSquared = Math.pow(brushSize + this.trueCircle, 2); @@ -123,7 +113,7 @@ public class DrainBrush extends Brush { v.sendMessage(ChatColor.AQUA + "Disc drain mode ON"); } } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipseBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipseBrush.java index 13d05b050..586e228a1 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipseBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipseBrush.java @@ -6,11 +6,6 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Ellipse_Brush - * - * @author psanker - */ public class EllipseBrush extends PerformBrush { private static final double TWO_PI = (2 * Math.PI); private static final int SCL_MIN = 1; @@ -25,9 +20,6 @@ public class EllipseBrush extends PerformBrush { private double stepSize; private boolean fill; - /** - * - */ public EllipseBrush() { this.setName("Ellipse"); } @@ -182,7 +174,7 @@ public class EllipseBrush extends PerformBrush { } @Override - public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) { + public final void parameters(final String[] par, final SnipeData v) { for (int i = 1; i < par.length; i++) { final String parameter = par[i]; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipsoidBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipsoidBrush.java index 00100bfa6..6202e4af5 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipsoidBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EllipsoidBrush.java @@ -6,18 +6,12 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Ellipsoid_Brush - */ public class EllipsoidBrush extends PerformBrush { private double xRad; private double yRad; private double zRad; private boolean istrue; - /** - * - */ public EllipsoidBrush() { this.setName("Ellipsoid"); } @@ -78,7 +72,7 @@ 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 SnipeData v) { this.istrue = false; for (int i = 1; i < par.length; i++) { final String parameter = par[i]; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityBrush.java index 2a9c0c5ee..70998fdae 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityBrush.java @@ -5,17 +5,10 @@ import com.thevoxelbox.voxelsniper.SnipeData; import org.bukkit.ChatColor; import org.bukkit.entity.EntityType; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Entity_Brush - * - * @author Piotr - */ + public class EntityBrush extends Brush { private EntityType entityType = EntityType.ZOMBIE; - /** - * - */ public EntityBrush() { this.setName("Entity"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityRemovalBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityRemovalBrush.java index e235281f0..03273c709 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityRemovalBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EntityRemovalBrush.java @@ -11,15 +11,9 @@ import java.util.Iterator; import java.util.List; import java.util.regex.PatternSyntaxException; -/** - * - */ public class EntityRemovalBrush extends Brush { private final List exemptions = new ArrayList<>(3); - /** - * - */ public EntityRemovalBrush() { this.setName("Entity Removal"); @@ -129,8 +123,8 @@ public class EntityRemovalBrush extends Brush { // +#/-# will suppress auto-prefixing final String exemptionPattern = currentParam.startsWith("+#") || currentParam.startsWith("-#") ? - currentParam.substring(2) : - (currentParam.contains(".") ? currentParam.substring(1) : ".*." + currentParam.substring(1)); + currentParam.substring(2) : + (currentParam.contains(".") ? currentParam.substring(1) : ".*." + currentParam.substring(1)); if (isAddOperation) { exemptions.add(exemptionPattern); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EraserBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EraserBrush.java index ca7028ce1..8d4c00c96 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EraserBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/EraserBrush.java @@ -10,11 +10,7 @@ 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 { private static final Set EXCLUSIVE_MATERIALS = EnumSet.of( @@ -22,9 +18,6 @@ public class EraserBrush extends Brush { private static final Set EXCLUSIVE_LIQUIDS = EnumSet.of( Material.WATER, Material.WATER, Material.LAVA, Material.LAVA); - /** - * - */ public EraserBrush() { this.setName("Eraser"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBlendBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBlendBrush.java index 3f81e05f4..281db0b0d 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBlendBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBlendBrush.java @@ -3,50 +3,50 @@ package com.thevoxelbox.voxelsniper.brush; import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; -public class ErodeBlendBrush extends Brush{ - - private BlendBallBrush blendBall; - private ErodeBrush erode; +public class ErodeBlendBrush extends Brush { - public ErodeBlendBrush() { - this.blendBall = new BlendBallBrush(); - this.erode = new ErodeBrush(); - this.setName("Erode BlendBall"); - } - - @Override - protected final void arrow(final SnipeData v) { - this.blendBall.excludeAir = false; - this.blendBall.setTargetBlock(this.getTargetBlock()); - this.blendBall.arrow(v); - this.erode.setTargetBlock(this.getTargetBlock()); - this.erode.arrow(v); - } - - @Override - protected final void powder(final SnipeData v) { - this.blendBall.excludeAir = false; - this.blendBall.setTargetBlock(this.getTargetBlock()); - this.blendBall.arrow(v); - this.erode.setTargetBlock(this.getTargetBlock()); - this.erode.powder(v); - } - - @Override - public final void parameters(final String[] par, final SnipeData v) { - this.blendBall.parameters(par, v); - this.erode.parameters(par, v); - } - - @Override - public String getPermissionNode() { - return "voxelsniper.brush.erodeblend"; - } + private BlendBallBrush blendBall; + private ErodeBrush erode; - @Override - public void info(Message vm) { - this.erode.info(vm); - this.blendBall.info(vm); - } + public ErodeBlendBrush() { + this.blendBall = new BlendBallBrush(); + this.erode = new ErodeBrush(); + this.setName("Erode BlendBall"); + } + + @Override + protected final void arrow(final SnipeData v) { + this.blendBall.excludeAir = false; + this.blendBall.setTargetBlock(this.getTargetBlock()); + this.blendBall.arrow(v); + this.erode.setTargetBlock(this.getTargetBlock()); + this.erode.arrow(v); + } + + @Override + protected final void powder(final SnipeData v) { + this.blendBall.excludeAir = false; + this.blendBall.setTargetBlock(this.getTargetBlock()); + this.blendBall.arrow(v); + this.erode.setTargetBlock(this.getTargetBlock()); + this.erode.powder(v); + } + + @Override + public final void parameters(final String[] par, final SnipeData v) { + this.blendBall.parameters(par, v); + this.erode.parameters(par, v); + } + + @Override + public String getPermissionNode() { + return "voxelsniper.brush.erodeblend"; + } + + @Override + public void info(Message vm) { + this.erode.info(vm); + this.blendBall.info(vm); + } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java index c8a69fa76..b2de663cd 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java @@ -22,20 +22,11 @@ import org.bukkit.util.Vector; import java.util.*; -/** - * http://www.voxelwiki.com/minecraft/VoxelSniper#The_Erosion_Brush - * - * @author Piotr - * @author MikeMatrix - */ 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); - /** - * - */ public ErodeBrush() { this.setName("Erode"); @@ -49,12 +40,6 @@ public class ErodeBrush extends Brush { } } - /** - * @param result - * @param player - * @param helpJSAP - * @return if a message was sent. - */ public static boolean sendHelpOrErrorMessageToPlayer(final JSAPResult result, final Player player, final HelpJSAP helpJSAP) { final List output = helpJSAP.writeHelpOrErrorMessageIfRequired(result); if (!output.isEmpty()) { @@ -252,11 +237,12 @@ public class ErodeBrush extends Brush { return "voxelsniper.brush.erode"; } - /** - * @author MikeMatrix - */ private enum Preset { - MELT(new ErosionPreset(2, 1, 5, 1)), FILL(new ErosionPreset(5, 1, 2, 1)), SMOOTH(new ErosionPreset(3, 1, 3, 1)), LIFT(new ErosionPreset(6, 0, 1, 1)), FLOATCLEAN(new ErosionPreset(6, 1, 6, 1)); + MELT(new ErosionPreset(2, 1, 5, 1)), + FILL(new ErosionPreset(5, 1, 2, 1)), + SMOOTH(new ErosionPreset(3, 1, 3, 1)), + LIFT(new ErosionPreset(6, 0, 1, 1)), + FLOATCLEAN(new ErosionPreset(6, 1, 6, 1)); private ErosionPreset preset; Preset(final ErosionPreset preset) { @@ -267,21 +253,20 @@ public class ErodeBrush extends Brush { * Generates a concat string of all options. * * @param seperator Seperator for delimiting entries. - * @return */ public static String getValuesString(String seperator) { - String valuesString = ""; + StringBuilder valuesString = new StringBuilder(); boolean delimiterHelper = true; for (final Preset preset : Preset.values()) { if (delimiterHelper) { delimiterHelper = false; } else { - valuesString += seperator; + valuesString.append(seperator); } - valuesString += preset.name(); + valuesString.append(preset.name()); } - return valuesString; + return valuesString.toString(); } public ErosionPreset getPreset() { @@ -291,9 +276,6 @@ public class ErodeBrush extends Brush { } - /** - * @author MikeMatrix - */ private static final class BlockChangeTracker { private final Map> blockChanges; private final Map flatChanges; @@ -307,7 +289,7 @@ public class ErodeBrush extends Brush { } public BlockWrapper get(final Vector position, final int iteration) { - BlockWrapper changedBlock = null; + BlockWrapper changedBlock; for (int i = iteration - 1; i >= 0; --i) { if (this.blockChanges.containsKey(i) && this.blockChanges.get(i).containsKey(position)) { @@ -339,16 +321,12 @@ public class ErodeBrush extends Brush { } } - /** - * @author MikeMatrix - */ private static final class BlockWrapper { private final AsyncBlock block; private final Material material; private final int data; - @SuppressWarnings("deprecation") public BlockWrapper(final AsyncBlock block) { this.block = block; this.data = block.getPropertyId(); @@ -411,9 +389,6 @@ public class ErodeBrush extends Brush { } - /** - * @author MikeMatrix - */ private static final class ErosionPreset { private final int erosionFaces; private final int erosionRecursion; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ExtrudeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ExtrudeBrush.java index 8b1556a21..1d67d60a4 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ExtrudeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ExtrudeBrush.java @@ -7,17 +7,9 @@ import org.bukkit.ChatColor; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Extrude_Brush - * - * @author psanker - */ public class ExtrudeBrush extends Brush { private double trueCircle; - /** - * - */ public ExtrudeBrush() { this.setName("Extrude"); } @@ -153,7 +145,7 @@ public class ExtrudeBrush extends Brush { } @Override - public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) { + public final void parameters(final String[] par, final SnipeData v) { for (int i = 1; i < par.length; i++) { final String parameter = par[i]; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FillDownBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FillDownBrush.java index 24ddb9de2..cd2315747 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FillDownBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FillDownBrush.java @@ -8,17 +8,12 @@ import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; import org.bukkit.block.Block; -/** - * @author Voxel - */ + public class FillDownBrush extends PerformBrush { private double trueCircle = 0; private boolean fillLiquid = true; private boolean fromExisting = false; - /** - * - */ public FillDownBrush() { this.setName("Fill Down"); } @@ -45,7 +40,9 @@ public class FillDownBrush extends PerformBrush { break; } } - if (!found) continue; + if (!found) { + continue; + } y--; } for (; y >= -targetBlock.getY(); --y) { @@ -110,7 +107,7 @@ public class FillDownBrush extends PerformBrush { 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."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FlatOceanBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FlatOceanBrush.java index 8a6a2018c..2044ed672 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FlatOceanBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/FlatOceanBrush.java @@ -6,23 +6,16 @@ import com.thevoxelbox.voxelsniper.SnipeData; import org.bukkit.ChatColor; import org.bukkit.Material; -/** - * @author GavJenks - */ 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; private int floorLevel = DEFAULT_FLOOR_LEVEL; - /** - * - */ 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++) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/GenerateTreeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/GenerateTreeBrush.java index c00b09828..3aed4ede9 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/GenerateTreeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/GenerateTreeBrush.java @@ -14,11 +14,6 @@ import java.util.Random; // Proposal: Use /v and /vr for leave and wood material // or two more parameters -- Monofraps -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#VoxelTrees_Brush - * - * @author Ghost8700 @ Voxel - */ public class GenerateTreeBrush extends Brush { // Tree Variables. private Random randGenerator = new Random(); @@ -35,7 +30,7 @@ public class GenerateTreeBrush extends Brush { private int thickness = 1; private int slopeChance = 40; private int twistChance = 5; // This is a hidden value not available through Parameters. Otherwise messy. - private int heightMininmum = 14; + private int heightMinimum = 14; private int heightMaximum = 18; private int branchLength = 8; private int nodeMax = 4; @@ -45,10 +40,7 @@ public class GenerateTreeBrush extends Brush { private int blockPositionY; private int blockPositionZ; - /** - * - */ - public GenerateTreeBrush() { +public GenerateTreeBrush() { this.setName("Generate Tree"); } @@ -81,7 +73,6 @@ 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) { // Sets branch origin. @@ -125,7 +116,6 @@ public class GenerateTreeBrush extends Brush { blockPositionZ = originZ; } - @SuppressWarnings("deprecation") private void leafNodeCreate() { // Generates the node size. final int nodeRadius = this.randGenerator.nextInt(this.nodeMax - this.nodeMin + 1) + this.nodeMin; @@ -223,7 +213,6 @@ public class GenerateTreeBrush extends Brush { * @param xDirection * @param zDirection */ - @SuppressWarnings("deprecation") private void rootCreate(final int xDirection, final int zDirection) { // Sets Origin. final int originX = blockPositionX; @@ -313,7 +302,6 @@ public class GenerateTreeBrush extends Brush { this.rootCreate(-1, -1); } - @SuppressWarnings("deprecation") 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); @@ -368,7 +356,7 @@ public class GenerateTreeBrush extends Brush { // ---------- // Main Trunk // ---------- - // Sets diretional preferences. + // Sets directional preferences. int xPreference = this.randGenerator.nextInt(this.slopeChance); int zPreference = this.randGenerator.nextInt(this.slopeChance); @@ -384,7 +372,7 @@ public class GenerateTreeBrush extends Brush { } // Generates a height for trunk. - int height = this.randGenerator.nextInt(this.heightMaximum - this.heightMininmum + 1) + this.heightMininmum; + int height = this.randGenerator.nextInt(this.heightMaximum - this.heightMinimum + 1) + this.heightMinimum; for (int p = 0; p < height; p++) { if (p > 3) { @@ -409,7 +397,7 @@ public class GenerateTreeBrush extends Brush { blockPositionY = blockPositionY + 1; } - // Generates branchs at top of trunk for each quadrant. + // Generates branches at top of trunk for each quadrant. this.branchCreate(1, 1); this.branchCreate(-1, 1); this.branchCreate(1, -1); @@ -423,7 +411,7 @@ public class GenerateTreeBrush extends Brush { // --------------- // Secondary Trunk // --------------- - // Sets diretional preferences. + // Sets directional preferences. xPreference = this.randGenerator.nextInt(this.slopeChance); zPreference = this.randGenerator.nextInt(this.slopeChance); @@ -439,7 +427,7 @@ public class GenerateTreeBrush extends Brush { } // Generates a height for trunk. - height = this.randGenerator.nextInt(this.heightMaximum - this.heightMininmum + 1) + this.heightMininmum; + height = this.randGenerator.nextInt(this.heightMaximum - this.heightMinimum + 1) + this.heightMinimum; if (height > 4) { for (int p = 0; p < height; p++) { @@ -463,7 +451,7 @@ public class GenerateTreeBrush extends Brush { blockPositionY = blockPositionY + 1; } - // Generates branchs at top of trunk for each quadrant. + // Generates branches at top of trunk for each quadrant. this.branchCreate(1, 1); this.branchCreate(-1, 1); this.branchCreate(1, -1); @@ -581,17 +569,17 @@ public class GenerateTreeBrush extends Brush { this.slopeChance = Integer.parseInt(parameter.replace("ts", "")); v.sendMessage(ChatColor.BLUE + "Trunk Slope set to " + this.slopeChance); } else if (parameter.startsWith("minh")) { // Height Minimum - this.heightMininmum = Integer.parseInt(parameter.replace("minh", "")); - 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!"); + this.heightMinimum = Integer.parseInt(parameter.replace("minh", "")); + if (this.heightMinimum > this.heightMaximum) { + this.heightMinimum = this.heightMaximum; + v.sendMessage(ChatColor.RED + "Minimum Height exceed than Maximum Height, has been set to " + this.heightMinimum + " Instead!"); } else { - v.sendMessage(ChatColor.BLUE + "Minimum Height set to " + this.heightMininmum); + v.sendMessage(ChatColor.BLUE + "Minimum Height set to " + this.heightMinimum); } } else if (parameter.startsWith("maxh")) { // Height Maximum this.heightMaximum = Integer.parseInt(parameter.replace("maxh", "")); - if (this.heightMininmum > this.heightMaximum) { - this.heightMaximum = this.heightMininmum; + if (this.heightMinimum > this.heightMaximum) { + this.heightMaximum = this.heightMinimum; v.sendMessage(ChatColor.RED + "Maximum Height can't be lower than Minimum Height, has been set to " + this.heightMaximum + " Instead!"); } else { v.sendMessage(ChatColor.BLUE + "Maximum Roots set to " + this.heightMaximum); @@ -619,14 +607,14 @@ public class GenerateTreeBrush extends Brush { this.minRoots = 1; this.thickness = 1; this.slopeChance = 40; - this.heightMininmum = 14; + this.heightMinimum = 14; this.heightMaximum = 18; this.branchLength = 8; this.nodeMax = 4; this.nodeMin = 3; v.sendMessage(ChatColor.GOLD + "Brush reset to default parameters."); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } catch (final Exception exception) { v.sendMessage(ChatColor.RED + "Invalid brush parameters! \"" + par[i] + "\" is not a valid statement. Please use the 'info' parameter to display parameter info."); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/HeatRayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/HeatRayBrush.java index 59271f70a..39e3350ce 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/HeatRayBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/HeatRayBrush.java @@ -13,27 +13,19 @@ 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 { - /** - * @author MikeMatrix - */ -// private enum FlameableBlock -// { -// WOOD(Material.WOOD), SAPLING(Material.SAPLING), LOG(Material.LOG), LEAVES(Material.LEAVES), SPONGE(Material.SPONGE), WEB(Material.WEB), LONG_GRASS(Material.LONG_GRASS), DEAD_BUSH(Material.DEAD_BUSH), WOOL(Material.WOOL), YELLOW_FLOWER(Material.YELLOW_FLOWER), RED_ROSE(Material.RED_ROSE), TORCH(Material.TORCH), FIRE(Material.FIRE), WOOD_STAIRS(Material.WOOD_STAIRS), CROPS(Material.CROPS), SIGN_POST(Material.SIGN_POST), WOODEN_DOOR(Material.WOODEN_DOOR), LADDER(Material.LADDER), WALL_SIGN(Material.WALL_SIGN), WOOD_PLATE(Material.WOOD_PLATE), SNOW(Material.SNOW), ICE(Material.ICE), SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK), FENCE(Material.FENCE), TRAP_DOOR(Material.TRAP_DOOR), VINE(Material.VINE), FENCE_GATE(Material.FENCE_GATE), WATER_LILLY(Material.WATER_LILY); -// -// private Material material; -// -// FlameableBlock(final Material material) -// { -// this.material = material; -// } -// } +/* private enum FlameableBlock + { + WOOD(Material.WOOD), SAPLING(Material.SAPLING), LOG(Material.LOG), LEAVES(Material.LEAVES), SPONGE(Material.SPONGE), WEB(Material.WEB), LONG_GRASS(Material.LONG_GRASS), DEAD_BUSH(Material.DEAD_BUSH), WOOL(Material.WOOL), YELLOW_FLOWER(Material.YELLOW_FLOWER), RED_ROSE(Material.RED_ROSE), TORCH(Material.TORCH), FIRE(Material.FIRE), WOOD_STAIRS(Material.WOOD_STAIRS), CROPS(Material.CROPS), SIGN_POST(Material.SIGN_POST), WOODEN_DOOR(Material.WOODEN_DOOR), LADDER(Material.LADDER), WALL_SIGN(Material.WALL_SIGN), WOOD_PLATE(Material.WOOD_PLATE), SNOW(Material.SNOW), ICE(Material.ICE), SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK), FENCE(Material.FENCE), TRAP_DOOR(Material.TRAP_DOOR), VINE(Material.VINE), FENCE_GATE(Material.FENCE_GATE), WATER_LILLY(Material.WATER_LILY); + + private Material material; + + FlameableBlock(final Material material) + { + this.material = material; + } + }*/ private static final double REQUIRED_OBSIDIAN_DENSITY = 0.6; private static final double REQUIRED_COBBLE_DENSITY = 0.5; @@ -84,7 +76,7 @@ public class HeatRayBrush extends Brush { if (currentLocation.toVector().isInSphere(targetLocation, v.getBrushSize())) { currentBlock = currentLocation.getBlock(); - if (currentBlock == null || currentBlock.getType() == Material.CHEST) { + if (currentBlock.getType() == Material.CHEST) { continue; } @@ -168,13 +160,13 @@ public class HeatRayBrush extends Brush { v.sendMessage(ChatColor.AQUA + "/b hr freq[float] -- Frequency parameter for the noise generator."); } if (parameter.startsWith("oct")) { - this.octaves = Integer.valueOf(parameter.replace("oct", "")); + this.octaves = Integer.parseInt(parameter.replace("oct", "")); v.getVoxelMessage().custom(ChatColor.GREEN + "Octaves: " + this.octaves); } else if (parameter.startsWith("amp")) { - this.amplitude = Double.valueOf(parameter.replace("amp", "")); + this.amplitude = Double.parseDouble(parameter.replace("amp", "")); v.getVoxelMessage().custom(ChatColor.GREEN + "Amplitude: " + this.amplitude); } else if (parameter.startsWith("freq")) { - this.frequency = Double.valueOf(parameter.replace("freq", "")); + this.frequency = Double.parseDouble(parameter.replace("freq", "")); v.getVoxelMessage().custom(ChatColor.GREEN + "Frequency: " + this.frequency); } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/IBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/IBrush.java index fa0c905a0..b2cfd6107 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/IBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/IBrush.java @@ -19,7 +19,7 @@ public interface IBrush { * Handles parameters passed to brushes. * * @param par Array of string containing parameters - * @param v Snipe Data + * @param v Snipe Data */ void parameters(String[] par, SnipeData v); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java index 43d7ea631..19951eec8 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JaggedLineBrush.java @@ -12,12 +12,6 @@ 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 { private static final Vector HALF_BLOCK_OFFSET = new Vector(0.5, 0.5, 0.5); private static final int RECURSION_MIN = 1; @@ -31,9 +25,6 @@ public class JaggedLineBrush extends PerformBrush { private int recursion = RECURSION_DEFAULT; private int spread = SPREAD_DEFAULT; - /** - * - */ public JaggedLineBrush() { this.setName("Jagged Line"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JockeyBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JockeyBrush.java index 74197c72b..da7194364 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JockeyBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/JockeyBrush.java @@ -12,20 +12,11 @@ import org.bukkit.event.player.PlayerTeleportEvent; import java.util.List; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Jockey_Brush - * - * @author Voxel - * @author Monofraps - */ public class JockeyBrush extends Brush { private static final int ENTITY_STACK_LIMIT = 50; private JockeyType jockeyType = JockeyType.NORMAL_ALL_ENTITIES; private Entity jockeyedEntity = null; - /** - * - */ public JockeyBrush() { this.setName("Jockey"); } @@ -139,16 +130,15 @@ public class JockeyBrush extends Brush { 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) { - boolean inverse = false; - boolean playerOnly = false; - boolean stack = false; try { + boolean inverse = false; + boolean playerOnly = false; + boolean stack = false; for (String parameter : par) { if (parameter.startsWith("-i:")) { inverse = parameter.endsWith("y"); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LightningBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LightningBrush.java index 75cef7cbb..8c123fa4c 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LightningBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LightningBrush.java @@ -3,13 +3,8 @@ package com.thevoxelbox.voxelsniper.brush; import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; -/** - * @author Gavjenks - */ public class LightningBrush extends Brush { - /** - * - */ + public LightningBrush() { this.setName("Lightning"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LineBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LineBrush.java index 604f41a97..9adf92ff0 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LineBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/LineBrush.java @@ -10,22 +10,12 @@ import org.bukkit.util.BlockIterator; import org.bukkit.util.NumberConversions; import org.bukkit.util.Vector; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Line_Brush - * - * @author Gavjenks - * @author giltwist - * @author MikeMatrix - */ 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(); private AsyncWorld targetWorld; - /** - * - */ public LineBrush() { this.setName("Line"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/MoveBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/MoveBrush.java index af20c2deb..236e2d794 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/MoveBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/MoveBrush.java @@ -17,7 +17,6 @@ import java.util.HashSet; /** * Moves a selection blockPositionY a certain amount. - * http://www.voxelwiki.com/minecraft/Voxelsniper#Move_Brush * * @author MikeMatrix */ @@ -31,9 +30,6 @@ public class MoveBrush extends Brush { */ private Selection selection = null; - /** - * - */ public MoveBrush() { this.setName("Move"); } @@ -151,13 +147,13 @@ public class MoveBrush extends Brush { v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]); } if (par[i].toLowerCase().startsWith("x")) { - this.moveDirections[0] = Integer.valueOf(par[i].substring(1)); + this.moveDirections[0] = Integer.parseInt(par[i].substring(1)); v.getVoxelMessage().custom(ChatColor.AQUA + "X direction set to: " + this.moveDirections[0]); } else if (par[i].toLowerCase().startsWith("y")) { - this.moveDirections[1] = Integer.valueOf(par[i].substring(1)); + this.moveDirections[1] = Integer.parseInt(par[i].substring(1)); v.getVoxelMessage().custom(ChatColor.AQUA + "Y direction set to: " + this.moveDirections[1]); } else if (par[i].toLowerCase().startsWith("z")) { - this.moveDirections[2] = Integer.valueOf(par[i].substring(1)); + this.moveDirections[2] = Integer.parseInt(par[i].substring(1)); v.getVoxelMessage().custom(ChatColor.AQUA + "Z direction set to: " + this.moveDirections[2]); } } @@ -182,13 +178,7 @@ public class MoveBrush extends Brush { * Calculated BlockStates of the selection. */ private final ArrayList blockStates = new ArrayList<>(); - /** - * - */ private Location location1 = null; - /** - * - */ private Location location2 = null; /** @@ -200,14 +190,14 @@ public class MoveBrush extends Brush { 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(); + final int lowX = Math.min(this.location1.getBlockX(), this.location2.getBlockX()); + final int lowY = Math.min(this.location1.getBlockY(), this.location2.getBlockY()); + final int lowZ = Math.min(this.location1.getBlockZ(), this.location2.getBlockZ()); + final int highX = Math.max(this.location1.getBlockX(), this.location2.getBlockX()); + final int highY = Math.max(this.location1.getBlockY(), this.location2.getBlockY()); + final int highZ = Math.max(this.location1.getBlockZ(), this.location2.getBlockZ()); if (Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY) > Selection.MAX_BLOCK_COUNT) { - throw new Exception(ChatColor.RED + "Selection size above hardcoded limit, please use a smaller selection."); + throw new Exception(ChatColor.RED + "Selection size above hardcoded limit of 5000000, please use a smaller selection."); } final AsyncWorld world = (AsyncWorld) this.location1.getWorld(); for (int y = lowY; y <= highY; y++) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OceanBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OceanBrush.java index 8a136fa55..d5dbfea87 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OceanBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OceanBrush.java @@ -9,11 +9,7 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_OCEANATOR_5000 - * - * @author Voxel - */ + 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; @@ -22,9 +18,6 @@ public class OceanBrush extends Brush { private int waterLevel = WATER_LEVEL_DEFAULT; private boolean coverFloor = false; - /** - * - */ public OceanBrush() { this.setName("OCEANATOR 5000(tm)"); } @@ -39,10 +32,6 @@ public class OceanBrush extends Brush { return 0; } - /** - * @param v - * @param undo - */ protected final void oceanator(final SnipeData v, final Undo undo) { final AsyncWorld world = this.getWorld(); @@ -55,7 +44,7 @@ public class OceanBrush extends Brush { 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; + final int newSeaFloorLevel = Math.max((this.waterLevel - wLevelDiff), LOW_CUT_LEVEL); final int highestY = this.getWorld().getHighestBlockYAt(x, z); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java index a7e1f98ed..7a7be93fa 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java @@ -10,19 +10,11 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Overlay_.2F_Topsoil_Brush - * - * @author Gavjenks - */ public class OverlayBrush extends PerformBrush { private static final int DEFAULT_DEPTH = 3; private int depth = DEFAULT_DEPTH; private boolean allBlocks = false; - /** - * - */ public OverlayBrush() { this.setName("Overlay (Topsoil Filling)"); } @@ -37,24 +29,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.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); + currentDepth, this.getTargetBlock().getZ() + z); if (isOverrideableMaterial(currentBlockId)) { this.current.perform( this.clampY(this.getTargetBlock().getX() + x, - currentDepth, this.getTargetBlock().getZ() + z)); + currentDepth, this.getTargetBlock().getZ() + z)); } } break; @@ -107,25 +99,25 @@ public class OverlayBrush extends PerformBrush { if ((Math.pow(x, 2) + Math.pow(z, 2)) <= 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) + this.getTargetBlock().getZ() + z) + .isEmpty()) { // if not a floating block (like one of Notch'world pools) if (this.getBlockAt(this.getTargetBlock().getX() + x, y + 1, - this.getTargetBlock().getZ() + z) + this.getTargetBlock().getZ() + z) .isEmpty()) { // must start at surface... this prevents it filling stuff in if // 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))); + this.getTargetBlock().getZ() + z))); BlockMaterial mat = type.getMaterial(); if (mat.isSolid() && mat.isFullCube() && !mat .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 + 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. @@ -137,8 +129,8 @@ public class OverlayBrush extends PerformBrush { 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.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. @@ -181,9 +173,9 @@ public class OverlayBrush extends PerformBrush { 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")) { @@ -207,7 +199,7 @@ public class OverlayBrush extends PerformBrush { 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."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PaintingBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PaintingBrush.java index 782b73de8..8e060b079 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PaintingBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PaintingBrush.java @@ -6,14 +6,11 @@ import com.thevoxelbox.voxelsniper.SnipeData; /** * Painting scrolling Brush. - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Painting_Picker_Brush * * @author Voxel */ public class PaintingBrush extends Brush { - /** - * - */ + public PaintingBrush() { this.setName("Painting"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PullBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PullBrush.java index 4ac1335ee..8b4d9c451 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PullBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PullBrush.java @@ -8,9 +8,7 @@ import org.bukkit.ChatColor; import java.util.HashSet; -/** - * @author Piotr - */ + public class PullBrush extends Brush { private final HashSet surface = new HashSet<>(); private int vh; @@ -244,9 +242,7 @@ public class PullBrush extends Brush { return "voxelsniper.brush.pull"; } - /** - * @author Piotr - */ + private final class BlockWrapper { private final int id; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PunishBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PunishBrush.java index 96452c027..6e0229ca4 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PunishBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/PunishBrush.java @@ -19,13 +19,6 @@ import org.bukkit.util.Vector; import java.util.List; import java.util.Random; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Punish_Brush - * - * @author Monofraps - * @author Deamon - * @author MikeMatrix - */ public class PunishBrush extends PerformBrush { private static final int MAXIMAL_RANDOM_TELEPORTATION_RANGE = 400; private static final int TICKS_PER_SECOND = 20; @@ -213,7 +206,7 @@ public class PunishBrush extends PerformBrush { } } catch (final Exception exception) { exception.printStackTrace(); - v.sendMessage("An error occured."); + v.sendMessage("An error occurred."); return; } } else if (v.getBrushSize() == PunishBrush.INFINIPUNISH_SIZE) { @@ -315,9 +308,6 @@ public class PunishBrush extends PerformBrush { return "voxelsniper.brush.punish"; } - /** - * @author Monofraps - */ private enum Punishment { // Monofraps FIRE, LIGHTNING, BLINDNESS, DRUNK, KILL, RANDOMTP, ALL_POTION, diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RandomErodeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RandomErodeBrush.java index 933c10668..4cc354f90 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RandomErodeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RandomErodeBrush.java @@ -8,12 +8,6 @@ import com.thevoxelbox.voxelsniper.Undo; import java.util.Random; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Random-Erode_Brush - * - * @author Piotr - * @author Giltwist (Randomized blockPositionY) - */ public class RandomErodeBrush extends Brush { private final double trueCircle = 0.5; private BlockWrapper[][][] snap; @@ -21,14 +15,10 @@ public class RandomErodeBrush extends Brush { private int bsize; private int erodeFace; private int fillFace; - private int brushSize; private int erodeRecursion = 1; private int fillRecursion = 1; private Random generator = new Random(); - /** - * - */ public RandomErodeBrush() { this.setName("RandomErode"); } @@ -60,7 +50,6 @@ public class RandomErodeBrush extends Brush { } } - @SuppressWarnings("deprecation") private boolean fill(final int x, final int y, final int z) { if (this.snap[x][y][z].isSolid()) { return false; @@ -95,19 +84,17 @@ public class RandomErodeBrush extends Brush { } private void getMatrix() { - this.brushSize = ((this.bsize + 1) * 2) + 1; + int brushSize = ((this.bsize + 1) * 2) + 1; if (this.snap.length == 0) { - this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize]; + this.snap = new BlockWrapper[brushSize][brushSize][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++) { - sz = this.getTargetBlock().getZ() - (this.bsize + 1); + int sz = this.getTargetBlock().getZ() - (this.bsize + 1); for (int z = 0; z < this.snap.length; z++) { - sy = this.getTargetBlock().getY() - (this.bsize + 1); + int sy = this.getTargetBlock().getY() - (this.bsize + 1); for (int y = 0; y < this.snap.length; y++) { this.snap[x][y][z] = new BlockWrapper(this.clampY(sx, sy, sz)); sy++; @@ -118,16 +105,14 @@ public class RandomErodeBrush extends Brush { } this.firstSnap = this.snap.clone(); } else { - this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize]; + this.snap = new BlockWrapper[brushSize][brushSize][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++) { - sz = this.getTargetBlock().getZ() - (this.bsize + 1); + int sz = this.getTargetBlock().getZ() - (this.bsize + 1); for (int z = 0; z < this.snap.length; z++) { - sy = this.getTargetBlock().getY() - (this.bsize + 1); + int sy = this.getTargetBlock().getY() - (this.bsize + 1); for (int y = 0; y < this.snap.length; y++) { this.snap[x][y][z] = new BlockWrapper(this.clampY(sx, sy, sz)); sy++; @@ -317,29 +302,18 @@ public class RandomErodeBrush extends Brush { return "voxelsniper.brush.randomerode"; } - /** - * @author unknown - */ private class BlockWrapper { private boolean solid; private AsyncBlock nativeBlock; private int id; private int i; - /** - * @param bl - */ - @SuppressWarnings("deprecation") public BlockWrapper(final AsyncBlock bl) { this.setNativeBlock(bl); this.setI(bl.getTypeId()); switch (bl.getType()) { case AIR: - this.setSolid(false); - break; case WATER: - this.setSolid(false); - break; case LAVA: this.setSolid(false); break; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RegenerateChunkBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RegenerateChunkBrush.java index 3ebf913b8..4653caee2 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RegenerateChunkBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RegenerateChunkBrush.java @@ -11,9 +11,7 @@ import org.bukkit.Chunk; * @author Mick */ public class RegenerateChunkBrush extends Brush { - /** - * - */ + public RegenerateChunkBrush() { this.setName("Chunk Generator 40k"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java index 33c5c60b3..9208276d9 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RingBrush.java @@ -6,18 +6,11 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Ring_Brush - * - * @author Voxel - */ + public class RingBrush extends PerformBrush { private double trueCircle = 0; private double innerSize = 0; - /** - * - */ public RingBrush() { this.setName("Ring"); } @@ -83,7 +76,7 @@ public class RingBrush extends PerformBrush { v.sendMessage(ChatColor.RED + "The parameters included are invalid."); } } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DBrush.java index 0981b3a13..187f75e09 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DBrush.java @@ -7,9 +7,7 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.util.BlockWrapper; import org.bukkit.ChatColor; -/** - * @author Piotr - */ + public class Rot2DBrush extends Brush { private int mode = 0; private int bSize; @@ -17,9 +15,6 @@ public class Rot2DBrush extends Brush { private BlockWrapper[][][] snap; private double se; - /** - * - */ public Rot2DBrush() { this.setName("2D Rotation"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DvertBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DvertBrush.java index ce26d0e39..ad0944e31 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DvertBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot2DvertBrush.java @@ -8,40 +8,31 @@ import com.thevoxelbox.voxelsniper.util.BlockWrapper; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -/** - * @author Gavjenks, hack job from the other 2d rotation brush blockPositionY piotr - */ // 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 { private int mode = 0; private int bSize; - private int brushSize; private BlockWrapper[][][] snap; private double se; - /** - * - */ public Rot2DvertBrush() { this.setName("2D Rotation"); } @SuppressWarnings("deprecation") private void getMatrix() { - this.brushSize = (this.bSize * 2) + 1; + int brushSize = (this.bSize * 2) + 1; - this.snap = new BlockWrapper[this.brushSize][this.brushSize][this.brushSize]; + this.snap = new BlockWrapper[brushSize][brushSize][brushSize]; int sx = this.getTargetBlock().getX() - this.bSize; - int sy = this.getTargetBlock().getY() - this.bSize; - int sz = this.getTargetBlock().getZ() - this.bSize; for (int x = 0; x < this.snap.length; x++) { - sz = this.getTargetBlock().getZ() - this.bSize; + int sz = this.getTargetBlock().getZ() - this.bSize; for (int z = 0; z < this.snap.length; z++) { - sy = this.getTargetBlock().getY() - this.bSize; + int sy = this.getTargetBlock().getY() - this.bSize; 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? @@ -56,7 +47,7 @@ public class Rot2DvertBrush extends Brush { } } - private void rotate(final SnipeData v) { + private void rotate() { final double brushSizeSquared = Math.pow(this.bSize + 0.5, 2); final double cos = Math.cos(this.se); final double sin = Math.sin(this.se); @@ -142,7 +133,7 @@ public class Rot2DvertBrush extends Brush { if (this.mode == 0) { this.getMatrix(); - this.rotate(v); + this.rotate(); } else { v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong."); } @@ -154,7 +145,7 @@ public class Rot2DvertBrush extends Brush { if (this.mode == 0) { this.getMatrix(); - this.rotate(v); + this.rotate(); } else { v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong."); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java index 954e4a3df..008d32d9e 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java @@ -8,9 +8,6 @@ import com.thevoxelbox.voxelsniper.Undo; import com.thevoxelbox.voxelsniper.util.BlockWrapper; import org.bukkit.ChatColor; -/** - * - */ public class Rot3DBrush extends Brush { private final int mode = 0; private int bSize; @@ -20,9 +17,6 @@ public class Rot3DBrush extends Brush { private double sePitch; private double seRoll; - /** - * - */ public Rot3DBrush() { this.setName("3D Rotation"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RulerBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RulerBrush.java index f051be30c..ce89391d6 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RulerBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/RulerBrush.java @@ -6,11 +6,6 @@ import com.thevoxelbox.voxelsniper.Undo; import org.bukkit.ChatColor; import org.bukkit.util.Vector; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Ruler_Brush - * - * @author Gavjenks - */ public class RulerBrush extends Brush { private boolean first = true; private Vector coords = new Vector(0, 0, 0); @@ -19,9 +14,6 @@ public class RulerBrush extends Brush { private int yOff = 0; private int zOff = 0; - /** - * - */ public RulerBrush() { this.setName("Ruler"); } @@ -93,7 +85,7 @@ public class RulerBrush extends Brush { this.xOff = 0; v.sendMessage(ChatColor.BLUE + "Ruler mode."); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java index 97b17ab5a..2761adf64 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java @@ -8,9 +8,6 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.BlockFace; -/** - * @author DivineRage - */ public class ScannerBrush extends Brush { private static final int DEPTH_MIN = 1; private static final int DEPTH_DEFAULT = 24; @@ -19,9 +16,6 @@ public class ScannerBrush extends Brush { private int depth = DEPTH_DEFAULT; private Material checkFor = Material.AIR; - /** - * - */ public ScannerBrush() { this.setName("Scanner"); } @@ -29,10 +23,8 @@ public class ScannerBrush extends Brush { private int clamp(final int value, final int min, final int max) { if (value < min) { return min; - } else if (value > max) { - return max; } else { - return value; + return Math.min(value, max); } } @@ -152,7 +144,7 @@ public class ScannerBrush extends Brush { 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 { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetBrush.java index 023a2c2d5..144901b57 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetBrush.java @@ -6,18 +6,11 @@ import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; import org.bukkit.block.Block; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Set_Brush - * - * @author Voxel - */ + public class SetBrush extends PerformBrush { private static final int SELECTION_SIZE_MAX = 5000000; private Block block = null; - /** - * - */ public SetBrush() { this.setName("Set"); } @@ -32,15 +25,15 @@ public class SetBrush extends PerformBrush { this.block = null; return true; } - final int lowX = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX(); - final int lowY = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY(); - final int lowZ = (this.block.getZ() <= bl.getZ()) ? this.block.getZ() : bl.getZ(); - final int highX = (this.block.getX() >= bl.getX()) ? this.block.getX() : bl.getX(); - final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY(); - final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ(); + final int lowX = Math.min(this.block.getX(), bl.getX()); + final int lowY = Math.min(this.block.getY(), bl.getY()); + final int lowZ = Math.min(this.block.getZ(), bl.getZ()); + final int highX = Math.max(this.block.getX(), bl.getX()); + final int highY = Math.max(this.block.getY(), bl.getY()); + final int highZ = Math.max(this.block.getZ(), bl.getZ()); if (Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY) > SELECTION_SIZE_MAX) { - v.sendMessage(ChatColor.RED + "Selection size above hardcoded limit, please use a smaller selection."); + v.sendMessage(ChatColor.RED + "Selection size above hardcoded limit of 5000000, please use a smaller selection."); } else { for (int y = lowY; y <= highY; y++) { for (int x = lowX; x <= highX; x++) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneFlipBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneFlipBrush.java index 2f8238290..7c5cd07f3 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneFlipBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneFlipBrush.java @@ -8,17 +8,12 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; -/** - * @author Voxel - */ + public class SetRedstoneFlipBrush extends Brush { private Block block = null; private Undo undo; private boolean northSouth = true; - /** - * - */ public SetRedstoneFlipBrush() { this.setName("Set Redstone Flip"); } @@ -29,12 +24,12 @@ public class SetRedstoneFlipBrush extends Brush { return true; } 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(); - final int lowZ = (this.block.getZ() <= bl.getZ()) ? this.block.getZ() : bl.getZ(); - final int highX = (this.block.getX() >= bl.getX()) ? this.block.getX() : bl.getX(); - final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY(); - final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ(); + final int lowX = Math.min(this.block.getX(), bl.getX()); + final int lowY = Math.min(this.block.getY(), bl.getY()); + final int lowZ = Math.min(this.block.getZ(), bl.getZ()); + final int highX = Math.max(this.block.getX(), bl.getX()); + final int highY = Math.max(this.block.getY(), bl.getY()); + final int highZ = Math.max(this.block.getZ(), bl.getZ()); for (int y = lowY; y <= highY; y++) { for (int x = lowX; x <= highX; x++) { @@ -110,7 +105,7 @@ public class SetRedstoneFlipBrush extends Brush { this.northSouth = false; v.sendMessage(ChatColor.AQUA + "Flip direction set to east/west."); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneRotateBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneRotateBrush.java index 29df0cf86..f0ad155bc 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneRotateBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SetRedstoneRotateBrush.java @@ -8,16 +8,11 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; -/** - * @author Voxel - */ + public class SetRedstoneRotateBrush extends Brush { private Block block = null; private Undo undo; - /** - * - */ public SetRedstoneRotateBrush() { this.setName("Set Redstone Rotate"); } @@ -28,12 +23,12 @@ public class SetRedstoneRotateBrush extends Brush { return true; } 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(); - final int lowZ = (this.block.getZ() <= bl.getZ()) ? this.block.getZ() : bl.getZ(); - final int highX = (this.block.getX() >= bl.getX()) ? this.block.getX() : bl.getX(); - final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY(); - final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ(); + final int lowX = Math.min(this.block.getX(), bl.getX()); + final int lowY = Math.min(this.block.getY(), bl.getY()); + final int lowZ = Math.min(this.block.getZ(), bl.getZ()); + final int highX = Math.max(this.block.getX(), bl.getX()); + final int highY = Math.max(this.block.getY(), bl.getY()); + final int highZ = Math.max(this.block.getZ(), bl.getZ()); for (int y = lowY; y <= highY; y++) { for (int x = lowX; x <= highX; x++) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellBallBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellBallBrush.java index 36164847b..d3be7c2fc 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellBallBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellBallBrush.java @@ -8,14 +8,11 @@ import org.bukkit.block.Block; /** * THIS BRUSH SHOULD NOT USE PERFORMERS. - * http://www.voxelwiki.com/minecraft/Voxelsniper#Shell_Brushes * * @author Voxel */ public class ShellBallBrush extends Brush { - /** - * - */ + public ShellBallBrush() { this.setName("Shell Ball"); } @@ -43,7 +40,7 @@ public class ShellBallBrush extends Brush { 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); } } @@ -103,7 +100,7 @@ public class ShellBallBrush extends Brush { } v.owner().storeUndo(undo); - // This is needed because most uses of this brush will not be sible to the sniper. + // This is needed because most uses of this brush will not be sible to the sible sniper. v.owner().getPlayer().sendMessage(ChatColor.AQUA + "Shell complete."); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellSetBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellSetBrush.java index 3c8c13fb1..701840f7b 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellSetBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellSetBrush.java @@ -9,18 +9,11 @@ import org.bukkit.block.Block; import java.util.ArrayList; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Shell_Brushes - * - * @author Piotr - */ + public class ShellSetBrush extends Brush { private static final int MAX_SIZE = 5000000; private Block block = null; - /** - * - */ public ShellSetBrush() { this.setName("Shell Set"); } @@ -37,18 +30,18 @@ public class ShellSetBrush extends Brush { return true; } - final int lowX = (this.block.getX() <= bl.getX()) ? this.block.getX() : bl.getX(); - final int lowY = (this.block.getY() <= bl.getY()) ? this.block.getY() : bl.getY(); - final int lowZ = (this.block.getZ() <= bl.getZ()) ? this.block.getZ() : bl.getZ(); - final int highX = (this.block.getX() >= bl.getX()) ? this.block.getX() : bl.getX(); - final int highY = (this.block.getY() >= bl.getY()) ? this.block.getY() : bl.getY(); - final int highZ = (this.block.getZ() >= bl.getZ()) ? this.block.getZ() : bl.getZ(); + final int lowX = Math.min(this.block.getX(), bl.getX()); + final int lowY = Math.min(this.block.getY(), bl.getY()); + final int lowZ = Math.min(this.block.getZ(), bl.getZ()); + final int highX = Math.max(this.block.getX(), bl.getX()); + final int highY = Math.max(this.block.getY(), bl.getY()); + final int highZ = Math.max(this.block.getZ(), bl.getZ()); - 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."); + int selectionSize = Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY); + if (selectionSize > MAX_SIZE) { + v.sendMessage(ChatColor.RED + "Selection size above hardcoded limit of 5000000, please use a smaller selection."); } else { - final ArrayList blocks = new ArrayList<>( - ((Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY)) / 2)); + final ArrayList blocks = new ArrayList<>(selectionSize / 2); for (int y = lowY; y <= highY; y++) { for (int x = lowX; x <= highX; x++) { for (int z = lowZ; z <= highZ; z++) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellVoxelBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellVoxelBrush.java index 6b77ddaa4..402280f5c 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellVoxelBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ShellVoxelBrush.java @@ -8,14 +8,11 @@ import org.bukkit.block.Block; /** * THIS BRUSH SHOULD NOT USE PERFORMERS. - * http://www.voxelwiki.com/minecraft/Voxelsniper#Shell_Brushes * * @author Voxel */ public class ShellVoxelBrush extends Brush { - /** - * - */ + public ShellVoxelBrush() { this.setName("Shell Voxel"); } @@ -42,7 +39,7 @@ public class ShellVoxelBrush extends Brush { 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; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SignOverwriteBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SignOverwriteBrush.java index f91bb8b3e..23aacafd7 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SignOverwriteBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SignOverwriteBrush.java @@ -8,10 +8,10 @@ import org.bukkit.block.BlockState; import org.bukkit.block.Sign; import java.io.*; +import java.util.Arrays; /** - * Overwrites signs. (Wiki: - * http://www.voxelwiki.com/minecraft/VoxelSniper#Sign_Overwrite_Brush) + * Overwrites signs. * * @author Monofraps */ @@ -27,9 +27,6 @@ public class SignOverwriteBrush extends Brush { private boolean[] signLinesEnabled = new boolean[NUM_SIGN_LINES]; private boolean rangedMode = false; - /** - * - */ public SignOverwriteBrush() { this.setName("Sign Overwrite Brush"); @@ -134,7 +131,7 @@ public class SignOverwriteBrush extends Brush { 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 arrow writes the internal line buffer to the target sign."); v.sendMessage(ChatColor.BLUE + "The powder reads the text of the target sign into the internal buffer."); v.sendMessage(ChatColor.AQUA + "Sign Overwrite Brush Parameters:"); v.sendMessage(ChatColor.GREEN + "-1[:(enabled|disabled)] ... " + ChatColor.BLUE + "-- Sets the text of the first sign line. (e.g. -1 Blah Blah)"); @@ -240,7 +237,7 @@ public class SignOverwriteBrush extends Brush { return i; } - String newText = ""; + StringBuilder newText = new StringBuilder(); // go through the array until the next top level parameter is found for (i++; i < params.length; i++) { @@ -250,16 +247,16 @@ public class SignOverwriteBrush extends Brush { i--; break; } else { - newText += currentParameter + " "; + newText.append(currentParameter).append(" "); } } - newText = ChatColor.translateAlternateColorCodes('&', newText); + newText = new StringBuilder(ChatColor.translateAlternateColorCodes('&', newText.toString())); // remove last space or return if the string is empty and the user just wanted to set the status - if (!newText.isEmpty() && newText.endsWith(" ")) { - newText = newText.substring(0, newText.length() - 1); - } else if (newText.isEmpty()) { + if ((newText.length() > 0) && newText.toString().endsWith(" ")) { + newText = new StringBuilder(newText.substring(0, newText.length() - 1)); + } else if (newText.length() == 0) { if (statusSet) { return i; } @@ -269,10 +266,10 @@ public class SignOverwriteBrush extends Brush { // check the line length and cut the text if needed 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); + newText = new StringBuilder(newText.substring(0, MAX_SIGN_LINE_LENGTH)); } - this.signTextLines[lineIndex] = newText; + this.signTextLines[lineIndex] = newText.toString(); return i; } @@ -298,17 +295,13 @@ public class SignOverwriteBrush extends Brush { try { store.createNewFile(); - FileWriter outFile = new FileWriter(store); - BufferedWriter outStream = new BufferedWriter(outFile); - - for (int i = 0; i < this.signTextLines.length; i++) { - outStream.write(this.signLinesEnabled[i] + "\n"); - outStream.write(this.signTextLines[i] + "\n"); + try (FileWriter outFile = new FileWriter(store); BufferedWriter outStream = new BufferedWriter(outFile)) { + for (int i = 0; i < this.signTextLines.length; i++) { + outStream.write(this.signLinesEnabled[i] + "\n"); + outStream.write(this.signTextLines[i] + "\n"); + } } - outStream.close(); - outFile.close(); - v.sendMessage(ChatColor.BLUE + "File saved successfully."); } catch (IOException exception) { v.sendMessage(ChatColor.RED + "Failed to save file. " + exception.getMessage()); @@ -330,18 +323,13 @@ public class SignOverwriteBrush extends Brush { return; } - try { - FileReader inFile = new FileReader(store); - BufferedReader inStream = new BufferedReader(inFile); + try (FileReader inFile = new FileReader(store); BufferedReader inStream = new BufferedReader(inFile)) { for (int i = 0; i < this.signTextLines.length; i++) { - this.signLinesEnabled[i] = Boolean.valueOf(inStream.readLine()); + this.signLinesEnabled[i] = Boolean.parseBoolean(inStream.readLine()); this.signTextLines[i] = inStream.readLine(); } - inStream.close(); - inFile.close(); - v.sendMessage(ChatColor.BLUE + "File loaded successfully."); } catch (IOException exception) { v.sendMessage(ChatColor.RED + "Failed to load file. " + exception.getMessage()); @@ -353,18 +341,14 @@ 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++) { - this.signTextLines[i] = ""; - } + Arrays.fill(this.signTextLines, ""); } /** * Resets line enabled states to enabled. */ private void resetStates() { - for (int i = 0; i < this.signLinesEnabled.length; i++) { - this.signLinesEnabled[i] = true; - } + Arrays.fill(this.signLinesEnabled, true); } @Override diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnipeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnipeBrush.java index 57ebee6b3..141642d9c 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnipeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnipeBrush.java @@ -4,15 +4,9 @@ import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Snipe_Brush - * - * @author Voxel - */ + public class SnipeBrush extends PerformBrush { - /** - * - */ + public SnipeBrush() { this.setName("Snipe"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java index 3e8e543d7..a79a19339 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java @@ -12,11 +12,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Snow_cone_brush - * - * @author Voxel - */ + public class SnowConeBrush extends Brush { @SuppressWarnings("deprecation") private void addSnow(final SnipeData v, Block targetBlock) { @@ -129,11 +125,11 @@ public class SnowConeBrush extends Brush { } 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."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java index f6e035a32..c76f92963 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java @@ -1,7 +1,6 @@ package com.thevoxelbox.voxelsniper.brush; import com.sk89q.worldedit.extension.input.InputParseException; -import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; @@ -9,24 +8,15 @@ import com.thevoxelbox.voxelsniper.Undo; import org.bukkit.ChatColor; import org.bukkit.block.Block; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Spiral_Staircase_Brush - * - * @author giltwist - */ 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 - /** - * - */ public SpiralStaircaseBrush() { this.setName("Spiral Staircase"); } - @SuppressWarnings("deprecation") private void buildStairWell(final SnipeData v, Block targetBlock) { if (v.getVoxelHeight() < 1) { v.setVoxelHeight(1); @@ -37,12 +27,9 @@ public class SpiralStaircaseBrush extends Brush { // locate first block in staircase // Note to self, fix these - int startX = 0; - int startZ = 0; + int startX; + int startZ; int y = 0; - int xOffset = 0; - int zOffset = 0; - int toggle = 0; if (this.sdirect.equalsIgnoreCase("cc")) { if (this.sopen.equalsIgnoreCase("n")) { @@ -74,6 +61,9 @@ public class SpiralStaircaseBrush extends Brush { } } + int xOffset = 0; + int zOffset = 0; + int toggle = 0; while (y < v.getVoxelHeight()) { if (this.stairtype.equalsIgnoreCase("block")) { // 1x1x1 voxel material steps @@ -223,9 +213,6 @@ public class SpiralStaircaseBrush extends Brush { break; case 1: - switch (stairtype) { - - } 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")) { @@ -258,7 +245,6 @@ public class SpiralStaircaseBrush extends Brush { v.owner().storeUndo(undo); } - @SuppressWarnings("deprecation") private void digStairWell(final SnipeData v, Block targetBlock) { if (v.getVoxelHeight() < 1) { v.setVoxelHeight(1); @@ -270,12 +256,8 @@ public class SpiralStaircaseBrush extends Brush { // locate first block in staircase // Note to self, fix these - int startX = 0; - int startZ = 0; - int y = 0; - int xOffset = 0; - int zOffset = 0; - int toggle = 0; + int startX; + int startZ; if (this.sdirect.equalsIgnoreCase("cc")) { if (this.sopen.equalsIgnoreCase("n")) { @@ -307,6 +289,10 @@ public class SpiralStaircaseBrush extends Brush { } } + int xOffset = 0; + int zOffset = 0; + int toggle = 0; + int y = 0; while (y < v.getVoxelHeight()) { if (this.stairtype.equalsIgnoreCase("block")) { // 1x1x1 voxel material steps @@ -522,14 +508,11 @@ public class SpiralStaircaseBrush extends Brush { // step/slab try { - BlockType type = BlockTypes.parse(par[i]); this.stairtype = par[i].toLowerCase().intern(); v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype); return; } 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")) { this.stairtype = par[i].toLowerCase().intern(); v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype); @@ -540,7 +523,7 @@ public class SpiralStaircaseBrush extends Brush { this.sopen = par[i]; v.sendMessage(ChatColor.BLUE + "Staircase opens: " + this.sopen); } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterBallBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterBallBrush.java index 77da630cf..dd8eb0970 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterBallBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterBallBrush.java @@ -8,11 +8,7 @@ import org.bukkit.ChatColor; import java.util.Random; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Splatter_Brushes - * - * @author Voxel - */ + public class SplatterBallBrush extends PerformBrush { private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_DEFAULT = 1000; @@ -28,9 +24,6 @@ public class SplatterBallBrush extends PerformBrush { private int splatterRecursions; // How many times you grow the seeds private Random generator = new Random(); - /** - * - */ public SplatterBallBrush() { this.setName("Splatter Ball"); } @@ -105,9 +98,10 @@ 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--) { - if (2 * v.getBrushSize() + 1 >= 0) + if (2 * v.getBrushSize() + 1 >= 0) { System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, - 2 * v.getBrushSize() + 1); + 2 * v.getBrushSize() + 1); + } } } } @@ -211,7 +205,7 @@ public class SplatterBallBrush extends PerformBrush { v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); } } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterDiscBrush.java index 14737c566..0243e90d1 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterDiscBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterDiscBrush.java @@ -8,11 +8,7 @@ import org.bukkit.ChatColor; import java.util.Random; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Splatter_Brushes - * - * @author Voxel - */ + public class SplatterDiscBrush extends PerformBrush { private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_DEFAULT = 1000; @@ -28,9 +24,6 @@ public class SplatterDiscBrush extends PerformBrush { private int splatterRecursions; // How many times you grow the seeds private Random generator = new Random(); - /** - * - */ public SplatterDiscBrush() { this.setName("Splatter Disc"); } @@ -95,8 +88,9 @@ public class SplatterDiscBrush extends PerformBrush { // integrate tempsplat back into splat at end of iteration for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - if (2 * v.getBrushSize() + 1 >= 0) + if (2 * v.getBrushSize() + 1 >= 0) { System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); + } } } this.growPercent = gref; @@ -186,7 +180,7 @@ public class SplatterDiscBrush extends PerformBrush { v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); } } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java index e1ac77253..ae01e60ed 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java @@ -10,11 +10,6 @@ import org.bukkit.ChatColor; import java.util.Random; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Splatter_Overlay_Brush - * - * @author Gavjenks Splatterized blockPositionY Giltwist - */ public class SplatterOverlayBrush extends PerformBrush { private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_DEFAULT = 1000; @@ -34,9 +29,6 @@ public class SplatterOverlayBrush extends PerformBrush { private int depth = 3; private boolean allBlocks = false; - /** - * - */ public SplatterOverlayBrush() { this.setName("Splatter Overlay"); } @@ -88,8 +80,9 @@ public class SplatterOverlayBrush extends PerformBrush { } // integrate tempsplat back into splat at end of iteration for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - if (2 * v.getBrushSize() + 1 >= 0) + if (2 * v.getBrushSize() + 1 >= 0) { System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); + } } } this.growPercent = gref; @@ -124,9 +117,6 @@ public class SplatterOverlayBrush extends PerformBrush { memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; } } - continue; - } else { - continue; } } else { final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth; @@ -197,8 +187,9 @@ public class SplatterOverlayBrush extends PerformBrush { } // integrate tempsplat back into splat at end of iteration for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - if (2 * v.getBrushSize() + 1 >= 0) + if (2 * v.getBrushSize() + 1 >= 0) { System.arraycopy(tempsplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); + } } } this.growPercent = gref; @@ -225,9 +216,6 @@ public class SplatterOverlayBrush extends PerformBrush { // 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 { final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth; @@ -338,10 +326,10 @@ public class SplatterOverlayBrush extends PerformBrush { v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); } } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } catch (Exception exception) { - v.sendMessage(String.format("An error occured while processing parameter %s.", parameter)); + v.sendMessage(String.format("An error occurred while processing parameter %s.", parameter)); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelBrush.java index 5c8c23313..19a9dfb36 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelBrush.java @@ -8,11 +8,7 @@ import org.bukkit.ChatColor; import java.util.Random; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Splatter_Brushes - * - * @author Voxel - */ + public class SplatterVoxelBrush extends PerformBrush { private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_DEFAULT = 1000; @@ -28,9 +24,6 @@ public class SplatterVoxelBrush extends PerformBrush { private int splatterRecursions; // How many times you grow the seeds private Random generator = new Random(); - /** - * - */ public SplatterVoxelBrush() { this.setName("Splatter Voxel"); } @@ -105,9 +98,10 @@ 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--) { - if (2 * v.getBrushSize() + 1 >= 0) + if (2 * v.getBrushSize() + 1 >= 0) { System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, - 2 * v.getBrushSize() + 1); + 2 * v.getBrushSize() + 1); + } } } } @@ -201,7 +195,7 @@ public class SplatterVoxelBrush extends PerformBrush { v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); } } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelDiscBrush.java index 98193318a..e9157cbfd 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelDiscBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterVoxelDiscBrush.java @@ -8,11 +8,7 @@ import org.bukkit.block.Block; import java.util.Random; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Splatter_Brushes - * - * @author Voxel - */ + public class SplatterVoxelDiscBrush extends PerformBrush { private static final int GROW_PERCENT_MIN = 1; private static final int GROW_PERCENT_DEFAULT = 1000; @@ -28,9 +24,6 @@ public class SplatterVoxelDiscBrush extends PerformBrush { private int splatterRecursions; // How many times you grow the seeds private Random generator = new Random(); - /** - * - */ public SplatterVoxelDiscBrush() { this.setName("Splatter Voxel Disc"); } @@ -92,8 +85,9 @@ public class SplatterVoxelDiscBrush extends PerformBrush { } // integrate tempsplat back into splat at end of iteration for (int x = 2 * v.getBrushSize(); x >= 0; x--) { - if (2 * v.getBrushSize() + 1 >= 0) + if (2 * v.getBrushSize() + 1 >= 0) { System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1); + } } } this.growPercent = gref; @@ -184,7 +178,7 @@ public class SplatterVoxelDiscBrush extends PerformBrush { v.sendMessage(ChatColor.RED + "Recursions must be an integer 1-10!"); } } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplineBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplineBrush.java index feb1db787..1b7d60bdd 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplineBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplineBrush.java @@ -43,7 +43,7 @@ public class SplineBrush extends PerformBrush { this.ctrlPts.add(targetBlock); v.sendMessage(ChatColor.GRAY + "Added block " + ChatColor.RED + "(" + targetBlock.getX() + ", " + targetBlock.getY() + ", " + targetBlock.getZ() + ") " + ChatColor.GRAY - + "to control point selection"); + + "to control point selection"); } public final void removeFromSet(final SnipeData v, final boolean ep, Block targetBlock) { @@ -55,7 +55,7 @@ public class SplineBrush extends PerformBrush { this.endPts.add(targetBlock); v.sendMessage(ChatColor.GRAY + "Removed block " + ChatColor.RED + "(" + targetBlock.getX() + ", " + targetBlock.getY() + ", " + targetBlock.getZ() + ") " + ChatColor.GRAY - + "from endpoint selection"); + + "from endpoint selection"); return; } @@ -66,7 +66,7 @@ public class SplineBrush extends PerformBrush { this.ctrlPts.remove(targetBlock); v.sendMessage(ChatColor.GRAY + "Removed block " + ChatColor.RED + "(" + targetBlock.getX() + ", " + targetBlock.getY() + ", " + targetBlock.getZ() + ") " + ChatColor.GRAY - + "from control point selection"); + + "from control point selection"); } public final boolean spline(final Point start, final Point end, final Point c1, final Point c2, final SnipeData v) { @@ -146,7 +146,7 @@ public class SplineBrush extends PerformBrush { } @Override - public final void parameters(final String[] par, final com.thevoxelbox.voxelsniper.SnipeData v) { + 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 + "Spline brush parameters"); @@ -181,7 +181,7 @@ public class SplineBrush extends PerformBrush { this.render(v); } } else { - v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StampBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StampBrush.java index 56b54c0b8..febd39ba5 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StampBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StampBrush.java @@ -9,9 +9,6 @@ import org.bukkit.ChatColor; import java.util.HashSet; -/** - * - */ public class StampBrush extends Brush { protected HashSet clone = new HashSet<>(); protected HashSet fall = new HashSet<>(); @@ -20,39 +17,24 @@ public class StampBrush extends Brush { protected Undo undo; protected boolean sorted = false; protected StampType stamp = StampType.DEFAULT; - /** - * - */ + public StampBrush() { this.setName("Stamp"); } - /** - * - */ + public final void reSort() { this.sorted = false; } - /** - * @param id - * @return - */ protected final boolean falling(final int id) { return (id > 7 && id < 14); } - /** - * @param id - * @return - */ protected final boolean fallsOff(final int id) { return (BlockTypes.get(id).getMaterial().isFragileWhenPushed()); } - /** - * @param cb - */ @SuppressWarnings("deprecation") 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); @@ -61,9 +43,6 @@ public class StampBrush extends Brush { block.setPropertyId(cb.d); } - /** - * @param cb - */ @SuppressWarnings("deprecation") 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); @@ -74,16 +53,10 @@ public class StampBrush extends Brush { } } - /** - * @param type - */ protected final void setStamp(final StampType type) { this.stamp = type; } - /** - * @param v - */ protected final void stamp(final SnipeData v) { this.undo = new Undo(); @@ -123,9 +96,6 @@ public class StampBrush extends Brush { v.owner().storeUndo(this.undo); } - /** - * @param v - */ protected final void stampFill(final SnipeData v) { this.undo = new Undo(); @@ -166,9 +136,6 @@ public class StampBrush extends Brush { v.owner().storeUndo(this.undo); } - /** - * @param v - */ protected final void stampNoAir(final SnipeData v) { this.undo = new Undo(); @@ -245,16 +212,11 @@ public class StampBrush extends Brush { return "voxelsniper.brush.stamp"; } - /** - * @author Monofraps - */ protected enum StampType { NO_AIR, FILL, DEFAULT } - /** - * @author Voxel - */ + protected class BlockWrapper { public int id; public int x; @@ -262,13 +224,6 @@ public class StampBrush extends Brush { 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(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilBrush.java index 38e8ea90d..1a6e9b82f 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilBrush.java @@ -42,10 +42,7 @@ public class StencilBrush extends Brush { private int[] pastePoint = new int[3]; private byte point = 1; - /** - * - */ - public StencilBrush() { +public StencilBrush() { this.setName("Stencil"); } @@ -60,8 +57,7 @@ public class StencilBrush extends Brush { final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil"); if (file.exists()) { - try { - final FaweInputStream in = new FaweInputStream(new DataInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file))))); + try (final FaweInputStream in = new FaweInputStream(new DataInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file)))))) { this.x = in.readShort(); this.z = in.readShort(); @@ -203,7 +199,7 @@ public class StencilBrush extends Brush { } } - @SuppressWarnings("deprecation") + @SuppressWarnings("UnstableApiUsage") private void stencilSave(final SnipeData v) { final File file = new File("plugins/VoxelSniper/stencils/" + this.filename + ".vstencil"); @@ -222,62 +218,62 @@ public class StencilBrush extends Brush { Files.createParentDirs(file); file.createNewFile(); - final FaweOutputStream out = new FaweOutputStream(new DataOutputStream(new PGZIPOutputStream(new BufferedOutputStream(new FileOutputStream(file))))); - int blockPositionX = (this.firstPoint[0] > this.secondPoint[0]) ? this.secondPoint[0] : this.firstPoint[0]; - int blockPositionZ = (this.firstPoint[1] > this.secondPoint[1]) ? this.secondPoint[1] : this.firstPoint[1]; - int blockPositionY = (this.firstPoint[2] > this.secondPoint[2]) ? this.secondPoint[2] : this.firstPoint[2]; - out.writeShort(this.x); - out.writeShort(this.z); - out.writeShort(this.y); - out.writeShort(this.xRef); - out.writeShort(this.zRef); - out.writeShort(this.yRef); + try (FaweOutputStream out = new FaweOutputStream(new DataOutputStream(new PGZIPOutputStream(new BufferedOutputStream(new FileOutputStream(file)))))) { + int blockPositionX = Math.min(this.firstPoint[0], this.secondPoint[0]); + int blockPositionZ = Math.min(this.firstPoint[1], this.secondPoint[1]); + int blockPositionY = Math.min(this.firstPoint[2], this.secondPoint[2]); + out.writeShort(this.x); + out.writeShort(this.z); + out.writeShort(this.y); + out.writeShort(this.xRef); + out.writeShort(this.zRef); + out.writeShort(this.yRef); - v.sendMessage(ChatColor.AQUA + "Volume: " + this.x * this.z * this.y + " blockPositionX:" + blockPositionX + " blockPositionZ:" + blockPositionZ + " blockPositionY:" + blockPositionY); + v.sendMessage(ChatColor.AQUA + "Volume: " + this.x * this.z * this.y + " blockPositionX:" + blockPositionX + " blockPositionZ:" + blockPositionZ + " blockPositionY:" + blockPositionY); - int[] blockArray = new int[this.x * this.z * this.y]; - byte[] runSizeArray = new byte[this.x * this.z * this.y]; + int[] blockArray = new int[this.x * this.z * this.y]; + byte[] runSizeArray = new byte[this.x * this.z * this.y]; - int lastId = (this.getWorld().getBlockAt(blockPositionX, blockPositionY, blockPositionZ).getCombinedId()); - 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++) { - AsyncBlock currentBlock = getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ + z); - thisId = (currentBlock.getCombinedId()); - if (thisId != lastId || counter == 255) { - blockArray[arrayIndex] = lastId; - runSizeArray[arrayIndex] = (byte) (counter - 128); - arrayIndex++; - counter = 1; - lastId = thisId; - } else { - counter++; - lastId = thisId; + int lastId = (this.getWorld().getBlockAt(blockPositionX, blockPositionY, blockPositionZ).getCombinedId()); + 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++) { + AsyncBlock currentBlock = getWorld().getBlockAt(blockPositionX + x, blockPositionY + y, blockPositionZ + z); + thisId = (currentBlock.getCombinedId()); + if (thisId != lastId || counter == 255) { + blockArray[arrayIndex] = lastId; + runSizeArray[arrayIndex] = (byte) (counter - 128); + arrayIndex++; + counter = 1; + lastId = thisId; + } else { + counter++; + lastId = thisId; + } } } } - } - blockArray[arrayIndex] = lastId; // saving last run, which will always be left over. - runSizeArray[arrayIndex] = (byte) (counter - 128); + blockArray[arrayIndex] = lastId; // saving last run, which will always be left over. + runSizeArray[arrayIndex] = (byte) (counter - 128); - out.writeInt(arrayIndex + 1); - // v.sendMessage("number of runs = " + arrayIndex); - for (int i = 0; i < arrayIndex + 1; i++) { - if (runSizeArray[i] > -127) { - out.writeBoolean(true); - out.writeByte(runSizeArray[i]); - out.writeVarInt(blockArray[i]); - } else { - out.writeBoolean(false); - out.writeVarInt(blockArray[i]); + out.writeInt(arrayIndex + 1); + // v.sendMessage("number of runs = " + arrayIndex); + for (int i = 0; i < arrayIndex + 1; i++) { + if (runSizeArray[i] > -127) { + out.writeBoolean(true); + out.writeByte(runSizeArray[i]); + out.writeVarInt(blockArray[i]); + } else { + out.writeBoolean(false); + out.writeVarInt(blockArray[i]); + } } - } - v.sendMessage(ChatColor.BLUE + "Saved as '" + this.filename + "'."); - out.close(); + v.sendMessage(ChatColor.BLUE + "Saved as '" + this.filename + "'."); + } } catch (final Exception exception) { v.sendMessage(ChatColor.RED + "Something went wrong."); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilListBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilListBrush.java index 3aced5cf1..40550c890 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilListBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/StencilListBrush.java @@ -12,9 +12,6 @@ import java.io.FileInputStream; import java.util.HashMap; import java.util.Scanner; -/** - * @author Gavjenks - */ public class StencilListBrush extends Brush { private byte pasteOption = 1; // 0 = full, 1 = fill, 2 = replace private String filename = "NoFileLoaded"; @@ -27,20 +24,17 @@ public class StencilListBrush extends Brush { private byte pasteParam = 0; private HashMap stencilList = new HashMap<>(); - /** - * - */ public StencilListBrush() { this.setName("StencilList"); } - private String readRandomStencil(final SnipeData v) { + private String readRandomStencil() { double rand = Math.random() * (this.stencilList.size()); final int choice = (int) rand; return this.stencilList.get(choice); } - private void readStencilList(final String listname, final SnipeData v) { + private void readStencilList() { final File file = new File("plugins/VoxelSniper/stencilLists/" + this.filename + ".txt"); if (file.exists()) { try { @@ -64,16 +58,14 @@ public class StencilListBrush extends Brush { return; } - final String stencilName = this.readRandomStencil(v); + final String stencilName = this.readRandomStencil(); v.sendMessage(stencilName); final Undo undo = new Undo(); final File file = new File("plugins/VoxelSniper/stencils/" + stencilName + ".vstencil"); if (file.exists()) { - try { - final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); - + try (final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)))){ this.x = in.readShort(); this.z = in.readShort(); this.y = in.readShort(); @@ -224,14 +216,13 @@ public class StencilListBrush extends Brush { return; } - final String stencilName = this.readRandomStencil(v); + final String stencilName = this.readRandomStencil(); final Undo undo = new Undo(); final File file = new File("plugins/VoxelSniper/stencils/" + stencilName + ".vstencil"); if (file.exists()) { - try { - final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); + try (final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)))) { this.x = in.readShort(); this.z = in.readShort(); @@ -383,14 +374,13 @@ public class StencilListBrush extends Brush { return; } - final String stencilName = this.readRandomStencil(v); + final String stencilName = this.readRandomStencil(); final Undo undo = new Undo(); final File file = new File("plugins/VoxelSniper/stencils/" + stencilName + ".vstencil"); if (file.exists()) { - try { - final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); + try (final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)))) { this.x = in.readShort(); this.z = in.readShort(); @@ -550,7 +540,7 @@ public class StencilListBrush extends Brush { return; } - final String stencilName = this.readRandomStencil(v); + final String stencilName = this.readRandomStencil(); final Undo undo = new Undo(); final File file = new File("plugins/VoxelSniper/stencils/" + stencilName + ".vstencil"); @@ -704,7 +694,7 @@ public class StencilListBrush extends Brush { private void stencilPasteRotation(final SnipeData v) { // just randomly chooses a rotation and then calls stencilPaste. - this.readStencilList(this.filename, v); + this.readStencilList(); final double random = Math.random(); if (random < 0.26) { this.stencilPaste(v); @@ -756,7 +746,7 @@ public class StencilListBrush extends Brush { final File file = new File("plugins/VoxelSniper/stencilLists/" + this.filename + ".txt"); if (file.exists()) { v.sendMessage(ChatColor.RED + "Stencil List '" + this.filename + "' exists and was loaded."); - this.readStencilList(this.filename, v); + this.readStencilList(); } else { v.sendMessage(ChatColor.AQUA + "Stencil List '" + this.filename + "' does not exist. This brush will not function without a valid stencil list."); this.filename = "NoFileLoaded"; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ThreePointCircleBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ThreePointCircleBrush.java index d1d60a8be..3a5c5500f 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ThreePointCircleBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ThreePointCircleBrush.java @@ -7,11 +7,6 @@ import org.bukkit.ChatColor; import org.bukkit.util.NumberConversions; import org.bukkit.util.Vector; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Three-Point_Circle_Brush - * - * @author Giltwist - */ public class ThreePointCircleBrush extends PerformBrush { private Vector coordsOne; private Vector coordsTwo; @@ -159,12 +154,12 @@ public class ThreePointCircleBrush extends PerformBrush { 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 = ""; + StringBuilder toleranceOptions = new StringBuilder(); for (final Tolerance tolerance : Tolerance.values()) { - if (!toleranceOptions.isEmpty()) { - toleranceOptions += "|"; + if (toleranceOptions.length() > 0) { + toleranceOptions.append("|"); } - toleranceOptions += tolerance.name().toLowerCase(); + toleranceOptions.append(tolerance.name().toLowerCase()); } v.sendMessage(ChatColor.GOLD + "/b tpc " + toleranceOptions + " -- Toggle the calculations to emphasize accuracy or smoothness"); return; @@ -193,7 +188,9 @@ public class ThreePointCircleBrush extends PerformBrush { * @author MikeMatrix */ private enum Tolerance { - DEFAULT(1000), ACCURATE(10), SMOOTH(2000); + DEFAULT(1000), + ACCURATE(10), + SMOOTH(2000); private int value; Tolerance(final int value) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TreeSnipeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TreeSnipeBrush.java index 4da34453d..f2ad22f41 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TreeSnipeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TreeSnipeBrush.java @@ -12,18 +12,9 @@ import org.bukkit.Material; import org.bukkit.TreeType; import org.bukkit.block.BlockFace; - -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Tree_Brush - * - * @author Mick - */ public class TreeSnipeBrush extends Brush { private TreeType treeType = TreeType.TREE; - /** - * - */ public TreeSnipeBrush() { this.setName("Tree Snipe"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TriangleBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TriangleBrush.java index ac02d8922..ac0a7d276 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TriangleBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/TriangleBrush.java @@ -5,11 +5,6 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Triangle_Brush - * - * @author Giltwist - */ public class TriangleBrush extends PerformBrush { private double[] coordsOne = new double[3]; // Three corners private double[] coordsTwo = new double[3]; @@ -21,9 +16,6 @@ public class TriangleBrush extends PerformBrush { private double[] vectorThree = new double[3]; // Point 2 to 3, for area calculations private double[] normalVector = new double[3]; - /** - * - */ public TriangleBrush() { this.setName("Triangle"); } @@ -62,10 +54,10 @@ public class TriangleBrush extends PerformBrush { } private void triangleP(final SnipeData v) { - double lengthOne = 0; - double lengthTwo = 0; - double lengthThree = 0; - double heronBig = 0; + double lengthOne; + double lengthTwo; + double lengthThree; + double heronBig; // Calculate slope vectors for (int i = 0; i < 3; i++) { @@ -85,7 +77,7 @@ public class TriangleBrush extends PerformBrush { lengthThree = Math.pow(Math.pow(this.vectorThree[0], 2) + Math.pow(this.vectorThree[1], 2) + Math.pow(this.vectorThree[2], 2), .5); // Bigger vector determines brush size - final int brushSize = (int) Math.ceil((lengthOne > lengthTwo) ? lengthOne : lengthTwo); + final int brushSize = (int) Math.ceil(Math.max(lengthOne, lengthTwo)); // Calculate constant term final double planeConstant = this.normalVector[0] * this.coordsOne[0] + this.normalVector[1] * this.coordsOne[1] + this.normalVector[2] * this.coordsOne[2]; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java index 9313e761d..db38e29ff 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java @@ -7,20 +7,11 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.ChatColor; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#Underlay_Brush - * - * @author jmck95 Credit to GavJenks for framework and 95 of code. Big Thank you to GavJenks - */ - public class UnderlayBrush extends PerformBrush { private static final int DEFAULT_DEPTH = 3; private int depth = DEFAULT_DEPTH; private boolean allBlocks = false; - /** - * - */ public UnderlayBrush() { this.setName("Underlay (Reverse Overlay)"); } @@ -48,8 +39,6 @@ public class UnderlayBrush extends PerformBrush { } break; - } else { - continue; } } else { for (int d = 0; (d < this.depth); d++) { @@ -91,8 +80,6 @@ public class UnderlayBrush extends PerformBrush { memory[x + v.getBrushSize()][z + v.getBrushSize()] = 1; // stop it from checking any other blocks in this vertical 1x1 column. } break; - } else { - continue; } } else { for (int d = -1; (d < this.depth - 1); d++) { @@ -148,7 +135,7 @@ public class UnderlayBrush extends PerformBrush { this.allBlocks = false; v.owner().getPlayer().sendMessage(ChatColor.BLUE + "Will underlay only natural block types." + this.depth); } else { - v.owner().getPlayer().sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info."); + v.owner().getPlayer().sendMessage(ChatColor.RED + "Invalid brush parameters! Use the info parameter to display parameter info."); } } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoltMeterBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoltMeterBrush.java index 5d6abc656..2ded259b0 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoltMeterBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoltMeterBrush.java @@ -7,20 +7,12 @@ import org.bukkit.ChatColor; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Volt-Meter_Brush - * - * @author Gavjenks - */ public class VoltMeterBrush extends Brush { - /** - * - */ + public VoltMeterBrush() { this.setName("VoltMeter"); } - @SuppressWarnings("deprecation") 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(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelBrush.java index 89cffd3fa..473e7e469 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelBrush.java @@ -4,15 +4,9 @@ import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Voxel_Brush - * - * @author Piotr - */ + public class VoxelBrush extends PerformBrush { - /** - * - */ + public VoxelBrush() { this.setName("Voxel"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscBrush.java index 12d468891..11f0c780d 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscBrush.java @@ -5,15 +5,9 @@ import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Voxel_Disc_Brush - * - * @author Voxel - */ + public class VoxelDiscBrush extends PerformBrush { - /** - * - */ + public VoxelDiscBrush() { this.setName("Voxel Disc"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscFaceBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscFaceBrush.java index 320e7c8e6..d6b795863 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscFaceBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/VoxelDiscFaceBrush.java @@ -6,15 +6,9 @@ import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -/** - * http://www.voxelwiki.com/minecraft/Voxelsniper#The_Voxel_Disc_Face_Brush - * - * @author Voxel - */ + public class VoxelDiscFaceBrush extends PerformBrush { - /** - * - */ + public VoxelDiscFaceBrush() { this.setName("Voxel Disc Face"); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WarpBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WarpBrush.java index 34d796c90..e242a5625 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WarpBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WarpBrush.java @@ -1,26 +1,26 @@ -/** - This file is part of VoxelSniper, licensed under the MIT License (MIT). +/* + This file is part of VoxelSniper, licensed under the MIT License (MIT). - Copyright (c) The VoxelBox - Copyright (c) contributors + Copyright (c) The VoxelBox + 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: + 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 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. + 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; @@ -32,21 +32,12 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; -/** - * @author MikeMatrix - */ public class WarpBrush extends Brush { - /** - * - */ + public WarpBrush() { this.setName("Warp"); } - public static Class inject() { - return WarpBrush.class; - } - @Override public final void info(final Message vm) { vm.brushName(this.getName()); @@ -88,4 +79,4 @@ public class WarpBrush extends Brush { public String getPermissionNode() { return "voxelsniper.brush.warp"; } -} \ No newline at end of file +} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java index d7c39db37..7ef13cfbb 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java @@ -6,6 +6,7 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; @@ -13,6 +14,7 @@ public class PatternPerformer extends vPerformer { private String info; private Pattern pattern; private Extent extent; + private final MutableBlockVector3 mutable = new MutableBlockVector3(); @Override public void info(Message vm) { @@ -31,7 +33,7 @@ public class PatternPerformer extends vPerformer { @Override public void perform(AsyncBlock block) { - BlockVector3 bv = BlockVector3.at(block.getX(), block.getY(), block.getZ()); + BlockVector3 bv = mutable.setComponents(block.getX(), block.getY(), block.getZ()); try { pattern.apply(extent, bv, bv); } catch (WorldEditException e) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformBrush.java index f12b8d646..5a874f194 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformBrush.java @@ -1,26 +1,26 @@ -/** - * This file is part of VoxelSniper, licensed under the MIT License (MIT). - *

- * Copyright (c) The VoxelBox - * 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). +

+ Copyright (c) The VoxelBox + 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. */ package com.thevoxelbox.voxelsniper.brush.perform; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/Performer.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/Performer.java index 5363d9a91..94d4094d8 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/Performer.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/Performer.java @@ -5,13 +5,12 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public interface Performer { - void parse(String[] args, com.thevoxelbox.voxelsniper.SnipeData v); + void parse(String[] args, SnipeData v); void showInfo(Message vm); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformerE.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformerE.java index 398ebafec..273d9a3df 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformerE.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformerE.java @@ -12,9 +12,7 @@ import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; -/** - * @author Voxel - */ + /* The m/i/c system of naming performers: [replacement-option][extras] * diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pCombo.java index d65a5d2f4..19697b650 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pCombo.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pCombo.java @@ -6,10 +6,8 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; -/** - * @author Voxel - */ public class pCombo extends vPerformer { private int i; @@ -27,7 +25,7 @@ public class pCombo extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); i = v.getVoxelId(); d = v.getPropertyId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboCombo.java index 9e8cbdb0e..ec39d01a4 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboCombo.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboCombo.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pComboCombo extends vPerformer { private int d; @@ -22,7 +21,7 @@ public class pComboCombo extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); dr = v.getReplaceData(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboComboNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboComboNoPhys.java index 611cba2fd..0034ab6c3 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboComboNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboComboNoPhys.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pComboComboNoPhys extends vPerformer { private int d; @@ -22,7 +21,7 @@ public class pComboComboNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); dr = v.getReplaceData(); @@ -53,4 +52,4 @@ public class pComboComboNoPhys extends vPerformer { public boolean isUsingReplaceMaterial() { return true; } -} \ No newline at end of file +} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInk.java index 61fc98e6b..c4ad7e7f9 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInk.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInk.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pComboInk extends vPerformer { private int d; @@ -21,7 +20,7 @@ public class pComboInk extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); dr = v.getReplaceData(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInkNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInkNoPhys.java index 23aecb643..baa1e7c41 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInkNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboInkNoPhys.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pComboInkNoPhys extends vPerformer { private int d; @@ -21,7 +20,7 @@ public class pComboInkNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); dr = v.getReplaceData(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMat.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMat.java index fca272002..c0fff13f1 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMat.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMat.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pComboMat extends vPerformer { private int d; @@ -21,7 +20,7 @@ public class pComboMat extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); i = v.getVoxelId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMatNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMatNoPhys.java index 989d28227..86f95a92c 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMatNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboMatNoPhys.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pComboMatNoPhys extends vPerformer { private int d; @@ -21,7 +20,7 @@ public class pComboMatNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); i = v.getVoxelId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoPhys.java index d4751538e..f591a1c50 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoPhys.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pComboNoPhys extends vPerformer { private int i; @@ -27,7 +26,7 @@ public class pComboNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); i = v.getVoxelId(); d = v.getPropertyId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoUndo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoUndo.java index 3312bdb2c..c1d08f3e0 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoUndo.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pComboNoUndo.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pComboNoUndo extends vPerformer { private int i; @@ -20,7 +19,7 @@ public class pComboNoUndo extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); i = v.getVoxelId(); d = v.getPropertyId(); @@ -40,4 +39,4 @@ public class pComboNoUndo extends vPerformer { b.setTypeIdAndPropertyId(i, d, true); } } -} \ No newline at end of file +} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeCombo.java index d9d7a6582..1531dac22 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeCombo.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeCombo.java @@ -6,11 +6,10 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.util.VoxelList; -/** - * @author Voxel - */ + public class pExcludeCombo extends vPerformer { private VoxelList excludeList; @@ -30,7 +29,7 @@ public class pExcludeCombo extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); id = v.getVoxelId(); data = v.getPropertyId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeInk.java index cd888ffc1..412a608e9 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeInk.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeInk.java @@ -6,11 +6,10 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.util.VoxelList; -/** - * @author Voxel - */ + public class pExcludeInk extends vPerformer { private VoxelList excludeList; @@ -28,7 +27,7 @@ public class pExcludeInk extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); data = v.getPropertyId(); excludeList = v.getVoxelList(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeMat.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeMat.java index cc08fd228..4eef243f8 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeMat.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pExcludeMat.java @@ -6,11 +6,10 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.util.VoxelList; -/** - * @author Voxel - */ + public class pExcludeMat extends vPerformer { private VoxelList excludeList; @@ -28,7 +27,7 @@ public class pExcludeMat extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); id = v.getVoxelId(); excludeList = v.getVoxelList(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeCombo.java index 42900375b..58134f7ae 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeCombo.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeCombo.java @@ -6,11 +6,10 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.util.VoxelList; -/** - * @author Voxel - */ + public class pIncludeCombo extends vPerformer { private VoxelList includeList; @@ -30,7 +29,7 @@ public class pIncludeCombo extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); id = v.getVoxelId(); data = v.getPropertyId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeInk.java index fed9e15c9..f8828956a 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeInk.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeInk.java @@ -6,11 +6,10 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.util.VoxelList; -/** - * @author Voxel - */ + public class pIncludeInk extends vPerformer { private VoxelList includeList; @@ -28,7 +27,7 @@ public class pIncludeInk extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); data = v.getPropertyId(); includeList = v.getVoxelList(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeMat.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeMat.java index d3af62180..4684581fb 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeMat.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pIncludeMat.java @@ -6,11 +6,10 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.util.VoxelList; -/** - * @author Voxel - */ + public class pIncludeMat extends vPerformer { private VoxelList includeList; @@ -28,7 +27,7 @@ public class pIncludeMat extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); id = v.getVoxelId(); includeList = v.getVoxelList(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInk.java index 90bce5498..4cec04c81 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInk.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInk.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pInk extends vPerformer { private int d; @@ -19,7 +18,7 @@ public class pInk extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkCombo.java index 4971662d5..81c603e21 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkCombo.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkCombo.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pInkCombo extends vPerformer { private int d; @@ -21,7 +20,7 @@ public class pInkCombo extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); dr = v.getReplaceData(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkComboNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkComboNoPhys.java index 530e9db6b..f3172ab95 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkComboNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkComboNoPhys.java @@ -2,10 +2,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pInkComboNoPhys extends vPerformer { private int d; @@ -17,7 +16,7 @@ public class pInkComboNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); dr = v.getReplaceData(); @@ -45,4 +44,4 @@ public class pInkComboNoPhys extends vPerformer { public boolean isUsingReplaceMaterial() { return true; } -} \ No newline at end of file +} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInk.java index 0bea5f28c..cf986654a 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInk.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInk.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pInkInk extends vPerformer { private int d; @@ -20,7 +19,7 @@ public class pInkInk extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); dr = v.getReplaceData(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInkNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInkNoPhys.java index 35097450f..dc1da32d8 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInkNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkInkNoPhys.java @@ -2,10 +2,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pInkInkNoPhys extends vPerformer { private int d; @@ -16,7 +15,7 @@ public class pInkInkNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); dr = v.getReplaceData(); @@ -42,4 +41,4 @@ public class pInkInkNoPhys extends vPerformer { public boolean isUsingReplaceMaterial() { return true; } -} \ No newline at end of file +} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMat.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMat.java index 244fc7db8..41a4b213f 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMat.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMat.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pInkMat extends vPerformer { private int d; @@ -20,7 +19,7 @@ public class pInkMat extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); ir = v.getReplaceId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMatNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMatNoPhys.java index dae7e0392..a6c932c5f 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMatNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkMatNoPhys.java @@ -2,10 +2,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pInkMatNoPhys extends vPerformer { private int d; @@ -16,7 +15,7 @@ public class pInkMatNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); ir = v.getReplaceId(); @@ -42,4 +41,4 @@ public class pInkMatNoPhys extends vPerformer { public boolean isUsingReplaceMaterial() { return true; } -} \ No newline at end of file +} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoPhys.java index 9564828bc..b27941c90 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoPhys.java @@ -2,10 +2,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pInkNoPhys extends vPerformer { private int d; @@ -15,7 +14,7 @@ public class pInkNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoUndo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoUndo.java index 2591b16eb..0cc598220 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoUndo.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pInkNoUndo.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pInkNoUndo extends vPerformer { private int d; @@ -19,7 +18,7 @@ public class pInkNoUndo extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); d = v.getPropertyId(); } @@ -37,4 +36,4 @@ public class pInkNoUndo extends vPerformer { b.setPropertyId(d); } } -} \ No newline at end of file +} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatCombo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatCombo.java index 10b4ebdef..1cc30bbdf 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatCombo.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatCombo.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pMatCombo extends vPerformer { private int dr; @@ -21,7 +20,7 @@ public class pMatCombo extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); dr = v.getReplaceData(); i = v.getVoxelId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatComboNophys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatComboNophys.java index f52358b2e..00ed5b0b2 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatComboNophys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatComboNophys.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pMatComboNophys extends vPerformer { private int dr; @@ -21,7 +20,7 @@ public class pMatComboNophys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); dr = v.getReplaceData(); i = v.getVoxelId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInk.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInk.java index d83bf3c55..d0d8dedf8 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInk.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInk.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pMatInk extends vPerformer { private int i; @@ -20,7 +19,7 @@ public class pMatInk extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); i = v.getVoxelId(); dr = v.getReplaceData(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInkNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInkNoPhys.java index a15d26551..bb825b048 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInkNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatInkNoPhys.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pMatInkNoPhys extends vPerformer { private int i; @@ -20,7 +19,7 @@ public class pMatInkNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); i = v.getVoxelId(); dr = v.getReplaceData(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMat.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMat.java index 10a7a731f..6faf085aa 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMat.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMat.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pMatMat extends vPerformer { private int i; @@ -20,7 +19,7 @@ public class pMatMat extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); i = v.getVoxelId(); r = v.getReplaceId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMatNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMatNoPhys.java index 83d80976d..66f4760c3 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMatNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMatMatNoPhys.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pMatMatNoPhys extends vPerformer { private int i; @@ -20,7 +19,7 @@ public class pMatMatNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); i = v.getVoxelId(); r = v.getReplaceId(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterial.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterial.java index 27bb4c16c..cf5e8d25e 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterial.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterial.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pMaterial extends vPerformer { private int i; @@ -19,7 +18,7 @@ public class pMaterial extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); i = v.getVoxelId(); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterialNoPhys.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterialNoPhys.java index 7a821570f..5471b0003 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterialNoPhys.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pMaterialNoPhys.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pMaterialNoPhys extends vPerformer { private int i; @@ -18,7 +17,7 @@ public class pMaterialNoPhys extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); i = v.getVoxelId(); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pNoUndo.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pNoUndo.java index f62affc6f..0c524cc1e 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pNoUndo.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/pNoUndo.java @@ -6,10 +6,9 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.thevoxelbox.voxelsniper.Message; +import com.thevoxelbox.voxelsniper.SnipeData; + -/** - * @author Voxel - */ public class pNoUndo extends vPerformer { private int i; @@ -19,7 +18,7 @@ public class pNoUndo extends vPerformer { } @Override - public void init(com.thevoxelbox.voxelsniper.SnipeData v) { + public void init(SnipeData v) { w = v.getWorld(); i = v.getVoxelId(); } @@ -37,4 +36,4 @@ public class pNoUndo extends vPerformer { b.setTypeId(i); } } -} \ No newline at end of file +} diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/vPerformer.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/vPerformer.java index 2201adf52..9f2be4a83 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/vPerformer.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/vPerformer.java @@ -6,12 +6,11 @@ package com.thevoxelbox.voxelsniper.brush.perform; 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.World; -/** - * @author Voxel - */ + public abstract class vPerformer { public String name = "Performer"; @@ -20,7 +19,7 @@ public abstract class vPerformer { public abstract void info(Message vm); - public abstract void init(com.thevoxelbox.voxelsniper.SnipeData v); + public abstract void init(SnipeData v); public void setUndo() { h = new Undo(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java index 4a0e4140d..3549a1d69 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java @@ -31,11 +31,7 @@ public class VoxelBrushToolCommand extends VoxelCommand { } if (args.length == 3 && args[2] != null && !args[2].isEmpty()) { - Material itemInHand = (player.getItemInHand() != null) ? player.getItemInHand().getType() : null; - if (itemInHand == null) { - player.sendMessage("/btool assign "); - return true; - } + Material itemInHand = player.getItemInHand().getType(); if (sniper.setTool(args[2], action, itemInHand)) { player.sendMessage(itemInHand.name() + " has been assigned to '" + args[2] + "' as action " + action.name() + "."); } else { @@ -48,11 +44,7 @@ public class VoxelBrushToolCommand extends VoxelCommand { sniper.removeTool(args[1]); return true; } else { - Material itemInHand = (player.getItemInHand() != null) ? player.getItemInHand().getType() : null; - if (itemInHand == null) { - player.sendMessage("Can't unassign empty hands."); - return true; - } + Material itemInHand = player.getItemInHand().getType(); if (sniper.getCurrentToolId() == null) { player.sendMessage("Can't unassign default tool."); return true; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java index 0e040ce4e..4bed75c2e 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java @@ -1,6 +1,5 @@ package com.thevoxelbox.voxelsniper.command; -import com.bekvon.bukkit.residence.commands.material; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -9,9 +8,6 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Sniper; import com.thevoxelbox.voxelsniper.VoxelSniper; import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; import org.bukkit.entity.Player; public class VoxelReplaceCommand extends VoxelCommand diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java index ad7601a75..c22f2e6d5 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java @@ -22,12 +22,11 @@ public class VoxelUndoCommand extends VoxelCommand { int amount = Integer.parseInt(args[0]); sniper.undo(amount); } catch (NumberFormatException exception) { - player.sendMessage(BBC.getPrefix() + "Number expected; string given."); + player.sendMessage("Number expected; string given."); } } else { sniper.undo(); } -// plugin.getLogger().info("Player \"" + player.getName() + "\" used /u"); return true; } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java index b574ced6c..0efdfcd0b 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java @@ -1,4 +1,4 @@ -/** +/* This file is part of VoxelSniper, licensed under the MIT License (MIT). Copyright (c) The VoxelBox @@ -25,7 +25,6 @@ package com.thevoxelbox.voxelsniper.command; -import com.bekvon.bukkit.residence.commands.material; import com.boydti.fawe.bukkit.favs.PatternUtil; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitAdapter; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushChangedEvent.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushChangedEvent.java index 3dd2b954b..37eb5f6d1 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushChangedEvent.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushChangedEvent.java @@ -1,4 +1,4 @@ -/** +/* This file is part of VoxelSniper, licensed under the MIT License (MIT). Copyright (c) The VoxelBox diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java index 3980b4e92..d7513a6a4 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java @@ -4,9 +4,6 @@ import com.thevoxelbox.voxelsniper.Sniper; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -/** - * - */ public class SniperBrushSizeChangedEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final Sniper sniper; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperMaterialChangedEvent.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperMaterialChangedEvent.java index e7801eb74..15d2e5a67 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperMaterialChangedEvent.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperMaterialChangedEvent.java @@ -1,4 +1,4 @@ -/** +/* This file is part of VoxelSniper, licensed under the MIT License (MIT). Copyright (c) The VoxelBox diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java index 453bd4797..fb65ad93b 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java @@ -4,9 +4,6 @@ import com.thevoxelbox.voxelsniper.Sniper; import org.bukkit.block.data.BlockData; import org.bukkit.event.HandlerList; -/** - * - */ public class SniperReplaceMaterialChangedEvent extends SniperMaterialChangedEvent { private static final HandlerList handlers = new HandlerList(); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/BlockWrapper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/BlockWrapper.java index 7b29aa1a5..c1f80200d 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/BlockWrapper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/BlockWrapper.java @@ -4,9 +4,6 @@ import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import org.bukkit.Material; import org.bukkit.World; -/** - * @author MikeMatrix - */ public class BlockWrapper { private int id; @@ -17,10 +14,6 @@ public class BlockWrapper { private int data; private World world; - /** - * @param block - */ - @SuppressWarnings("deprecation") public BlockWrapper(final AsyncBlock block) { this.setId(block.getTypeId()); this.setX(block.getX()); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/UndoDelegate.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/UndoDelegate.java index 0cf10403c..e9e30cffe 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/UndoDelegate.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/UndoDelegate.java @@ -6,9 +6,6 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; -/** - * - */ public class UndoDelegate implements BlockChangeDelegate { private final World targetWorld; private Undo currentUndo; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java index 34fd3c4d0..a5874f10e 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java @@ -1,18 +1,11 @@ package com.thevoxelbox.voxelsniper.util; -import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.function.mask.BlockMask; -import com.sk89q.worldedit.function.mask.BlockMaskBuilder; import com.sk89q.worldedit.world.block.BlockState; -import org.bukkit.Material; import org.bukkit.block.data.BlockData; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - /** * Container class for multiple ID/Datavalue pairs. */ diff --git a/favs/src/main/resources/config.yml b/favs/src/main/resources/config.yml index 0f9d5b5a4..ca761cbb6 100644 --- a/favs/src/main/resources/config.yml +++ b/favs/src/main/resources/config.yml @@ -1,3 +1,4 @@ -litesniper-max-brush-size: 5 -undo-cache-size: 20 +# Max. brush size for FAVS brushes +litesniper-max-brush-size: 30 +# Enable or disable the brush dump on login message-on-login-enabled: true \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 4c96db613..a9c7e611e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,11 @@ rootProject.name = 'FastAsyncWorldEdit' -include 'worldedit-core', 'worldedit-bukkit', 'favs' \ No newline at end of file +include 'worldedit-libs' + +['bukkit', 'core'].forEach { + include "worldedit-libs:$it" + include "worldedit-$it" +} +include "worldedit-libs:core:ap" + +include 'favs' diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index 42df6e565..32d95545a 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -1,21 +1,33 @@ apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'maven' +apply plugin: 'java-library' repositories { maven { url "https://hub.spigotmc.org/nexus/content/groups/public" } maven { url "https://repo.codemc.org/repository/maven-public" } - maven { url 'https://papermc.io/repo/repository/maven-public/' } + maven { url "https://papermc.io/repo/repository/maven-public/" } + flatDir { + dirs 'lib' + } +} + +configurations.all { Configuration it -> + it.resolutionStrategy { ResolutionStrategy rs -> + rs.force("com.google.guava:guava:21.0") + } } dependencies { - compile project(':worldedit-core') - compile 'org.bukkit:craftbukkit-1.14:pre5' + api project(':worldedit-core') + api project(':worldedit-libs:bukkit') compile 'net.milkbowl.vault:VaultAPI:1.7' - compile 'com.sk89q:dummypermscompat:1.10' - compile 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT' - compile 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT' - compile 'org.slf4j:slf4j-jdk14:1.7.26' + compile 'com.destroystokyo.paper:paper-api:1.14.3-R0.1-SNAPSHOT' + implementation 'io.papermc:paperlib:1.0.2' + compileOnly 'com.sk89q:dummypermscompat:1.10' +// compile 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT' + compile name: 'spigot-1.14.3' + implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.8.1' testCompile 'org.mockito:mockito-core:1.9.0-rc1' compile 'com.massivecraft:factions:2.8.0' compile 'com.drtshock:factions:1.6.9.5' @@ -81,9 +93,13 @@ task copyFiles { shadowJar { dependencies { relocate "org.slf4j", "com.sk89q.worldedit.slf4j" + relocate "org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge" include(dependency(':worldedit-core')) include(dependency('org.slf4j:slf4j-api')) - include(dependency("org.slf4j:slf4j-jdk14")) + include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) + relocate ("io.papermc.lib", "com.sk89q.worldedit.bukkit.paperlib") { + include(dependency("io.papermc:paperlib:1.0.2")) + } } archiveName = "${parent.name}-${project.name.replaceAll("worldedit-", "")}-${parent.version}.jar" destinationDir = file '../target' diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java index 083fe3304..7904a62f7 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java @@ -7,6 +7,7 @@ import com.boydti.fawe.object.FawePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; public class BukkitCommand implements CommandExecutor { @@ -17,7 +18,7 @@ public class BukkitCommand implements CommandExecutor { } @Override - public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { + public boolean onCommand(@NotNull final CommandSender sender, final Command cmd, final String label, final String[] args) { final FawePlayer plr = Fawe.imp().wrap(sender); if (!sender.hasPermission(this.cmd.getPerm()) && !sender.isOp()) { BBC.NO_PERM.send(plr, this.cmd.getPerm()); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java index 25eea21b9..17fe87fa7 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java @@ -2,20 +2,15 @@ package com.boydti.fawe.bukkit; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.BBC; -import com.boydti.fawe.object.FaweLocation; import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.wrappers.PlayerWrapper; -import java.lang.reflect.Method; -import java.util.UUID; - -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; +import java.util.UUID; + public class BukkitPlayer extends FawePlayer { private static ConsoleCommandSender console; @@ -66,21 +61,11 @@ public class BukkitPlayer extends FawePlayer { @Override public void resetTitle() { - sendTitle("",""); + parent.resetTitle(); } public void sendTitle(String title, String sub) { - try { - Method methodSendTitle = Player.class.getDeclaredMethod("sendTitle", String.class, String.class, int.class, int.class, int.class); - methodSendTitle.invoke(parent, ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20); - return; - } catch (Throwable ignore) { - try { - Method methodSendTitle = Player.class.getDeclaredMethod("sendTitle", String.class, String.class); - methodSendTitle.invoke(parent, ChatColor.GOLD + title, ChatColor.GOLD + sub); - return; - } catch (Throwable ignore2) {} - } + parent.sendTitle(ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20); if (console == null) { console = Bukkit.getConsoleSender(); Bukkit.getServer().dispatchCommand(console, "gamerule sendCommandFeedback false"); @@ -95,15 +80,13 @@ public class BukkitPlayer extends FawePlayer { this.parent.sendMessage(BBC.color(message)); } - @Override - public void executeCommand(final String cmd) { - Bukkit.getServer().dispatchCommand(this.parent, cmd); + @Override public void printError(String msg) { + this.sendMessage(msg); } @Override - public FaweLocation getLocation() { - final Location loc = this.parent.getLocation(); - return new FaweLocation(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + public void executeCommand(final String cmd) { + Bukkit.getServer().dispatchCommand(this.parent, cmd); } @Override diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 296ef8e53..7a785843d 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -61,7 +61,6 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.UUID; public class FaweBukkit implements IFawe, Listener { @@ -73,9 +72,7 @@ public class FaweBukkit implements IFawe, Listener { private boolean listeningImages; private BukkitImageListener imageListener; - private CFIPacketListener packetListener; - - private boolean listeningCui; + //private CFIPacketListener packetListener; public VaultUtil getVault() { return this.vault; @@ -106,11 +103,11 @@ public class FaweBukkit implements IFawe, Listener { } try { Fawe.get().setChatManager(new BukkitChatManager()); - } catch (Throwable ignore) { - ignore.printStackTrace(); + } catch (Throwable throwable) { + throwable.printStackTrace(); } } catch (final Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); Bukkit.getServer().shutdown(); } @@ -131,29 +128,34 @@ public class FaweBukkit implements IFawe, Listener { } try { - Class.forName("com.destroystokyo.paper.event.server.AsyncTabCompleteEvent"); + Class.forName("com.destroystokyo.paper.event.server.AsyncTabCompleteEvent"); Bukkit.getPluginManager().registerEvents(new AsyncTabCompleteListener(WorldEditPlugin.getInstance()), plugin); } catch (Throwable ignore) { - ignore.printStackTrace(); + debug("====== USE PAPER ======"); + debug("DOWNLOAD: https://papermc.io/ci/job/Paper-1.13/"); + debug("GUIDE: https://www.spigotmc.org/threads/21726/"); + debug(" - This is only a recommendation"); + debug(" - Allows the use of Async Tab Completetion as provided by Paper"); + debug("=============================="); Bukkit.getPluginManager().registerEvents(new SyncTabCompleteListener(WorldEditPlugin.getInstance()), plugin); } }); } - @Override - public void registerPacketListener() { - PluginManager manager = Bukkit.getPluginManager(); - if (packetListener == null && manager.getPlugin("ProtocolLib") != null) { - packetListener = new CFIPacketListener(plugin); - } - } +// @Override // Please don't delete this again, it's WIP +// public void registerPacketListener() { +// PluginManager manager = Bukkit.getPluginManager(); +// if (packetListener == null && manager.getPlugin("ProtocolLib") != null) { +// packetListener = new CFIPacketListener(plugin); +// } +// } @Override public synchronized ImageViewer getImageViewer(FawePlayer fp) { if (listeningImages && imageListener == null) return null; try { listeningImages = true; - registerPacketListener(); + //registerPacketListener(); PluginManager manager = Bukkit.getPluginManager(); if (manager.getPlugin("PacketListenerApi") == null) { @@ -197,13 +199,9 @@ public class FaweBukkit implements IFawe, Listener { } @Override - public void debug(final String s) { + public void debug(final String message) { ConsoleCommandSender console = Bukkit.getConsoleSender(); - if (console != null) { - console.sendMessage(BBC.color(s)); - } else { - Bukkit.getLogger().info(BBC.color(s)); - } + console.sendMessage(BBC.color(message)); } @Override @@ -239,7 +237,7 @@ public class FaweBukkit implements IFawe, Listener { Player player = (Player) obj; FawePlayer existing = Fawe.get().getCachedPlayer(player.getName()); return existing != null ? existing : new BukkitPlayer(player); - } else if (obj != null && obj.getClass().getName().contains("EntityPlayer")) { + } else if (obj.getClass().getName().contains("EntityPlayer")) { try { Method method = obj.getClass().getDeclaredMethod("getBukkitEntity"); return wrap(method.invoke(obj)); @@ -280,14 +278,13 @@ public class FaweBukkit implements IFawe, Listener { try { this.vault = new VaultUtil(); } catch (final Throwable e) { - this.debug(BBC.getPrefix() + "&dVault is used for persistent `/wea` toggles."); + this.debug("&dVault is used for persistent `/wea` toggles."); } } @Override public String getDebugInfo() { StringBuilder msg = new StringBuilder(); - List pl = new ArrayList<>(); msg.append("server.version: " + Bukkit.getVersion() + "\n"); msg.append("Plugins: \n"); for (Plugin p : Bukkit.getPluginManager().getPlugins()) { @@ -323,7 +320,7 @@ public class FaweBukkit implements IFawe, Listener { } try { return getQueue(world); - } catch (Throwable ignore) { + } catch (Throwable throwable) { // Disable incompatible settings Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level Settings.IMP.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI @@ -338,7 +335,7 @@ public class FaweBukkit implements IFawe, Listener { debug("Download the version of FAWE for your platform"); debug(" - http://ci.athion.net/job/FastAsyncWorldEdit/lastSuccessfulBuild/artifact/target"); debug("======================================="); - ignore.printStackTrace(); + throwable.printStackTrace(); debug("======================================="); TaskManager.IMP.laterAsync( () -> MainUtil.sendAdmin("&cNo NMS placer found, see console!"), 1); @@ -371,11 +368,11 @@ public class FaweBukkit implements IFawe, Listener { } catch (Throwable ignore) { } } - Throwable error = null; + Throwable error; try { return getQueue(world); - } catch (Throwable ignore) { - error = ignore; + } catch (Throwable throwable) { + error = throwable; } // Disable incompatible settings Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level @@ -422,7 +419,7 @@ public class FaweBukkit implements IFawe, Listener { managers.add(new WorldguardFlag(worldguardPlugin, this)); Fawe.debug("Plugin 'WorldGuard' found. Using it now."); } catch (final Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } } final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny"); @@ -431,13 +428,13 @@ public class FaweBukkit implements IFawe, Listener { managers.add(new TownyFeature(townyPlugin, this)); Fawe.debug("Plugin 'Towny' found. Using it now."); } catch (final Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } } final Plugin factionsPlugin = Bukkit.getServer().getPluginManager().getPlugin("Factions"); if ((factionsPlugin != null) && factionsPlugin.isEnabled()) { try { - managers.add(new FactionsFeature(factionsPlugin, this)); + managers.add(new FactionsFeature(factionsPlugin)); Fawe.debug("Plugin 'Factions' found. Using it now."); } catch (final Throwable e) { try { @@ -445,10 +442,10 @@ public class FaweBukkit implements IFawe, Listener { Fawe.debug("Plugin 'FactionsUUID' found. Using it now."); } catch (Throwable e2) { try { - managers.add(new FactionsOneFeature(factionsPlugin, this)); + managers.add(new FactionsOneFeature(factionsPlugin)); Fawe.debug("Plugin 'FactionsUUID' found. Using it now."); } catch (Throwable e3) { - MainUtil.handleError(e); + e.printStackTrace(); } } @@ -460,16 +457,16 @@ public class FaweBukkit implements IFawe, Listener { managers.add(new ResidenceFeature(residencePlugin, this)); Fawe.debug("Plugin 'Residence' found. Using it now."); } catch (final Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } } final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention"); if ((griefpreventionPlugin != null) && griefpreventionPlugin.isEnabled()) { try { - managers.add(new GriefPreventionFeature(griefpreventionPlugin, this)); + managers.add(new GriefPreventionFeature(griefpreventionPlugin)); Fawe.debug("Plugin 'GriefPrevention' found. Using it now."); } catch (final Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } } final Plugin preciousstonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones"); @@ -478,7 +475,7 @@ public class FaweBukkit implements IFawe, Listener { managers.add(new PreciousStonesFeature(preciousstonesPlugin, this)); Fawe.debug("Plugin 'PreciousStones' found. Using it now."); } catch (final Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } } @@ -486,10 +483,10 @@ public class FaweBukkit implements IFawe, Listener { final Plugin aSkyBlock = Bukkit.getServer().getPluginManager().getPlugin("ASkyBlock"); if ((aSkyBlock != null) && aSkyBlock.isEnabled()) { try { - managers.add(new ASkyBlockHook(aSkyBlock, this)); + managers.add(new ASkyBlockHook(aSkyBlock)); Fawe.debug("Plugin 'ASkyBlock' found. Using it now."); } catch (final Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } } if (Settings.IMP.EXPERIMENTAL.FREEBUILD) { @@ -497,7 +494,7 @@ public class FaweBukkit implements IFawe, Listener { managers.add(new FreeBuildRegion()); Fawe.debug("Plugin '' found. Using it now."); } catch (final Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } } @@ -571,7 +568,7 @@ public class FaweBukkit implements IFawe, Listener { BukkitQueue_0.checkVersion(v.name()); this.version = tmp = v; break; - } catch (IllegalStateException e) {} + } catch (IllegalStateException ignored) {} } } return tmp; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/BlockMaterial_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/BlockMaterial_1_13.java index 53a59d24d..0711a6961 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/BlockMaterial_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/BlockMaterial_1_13.java @@ -1,9 +1,11 @@ package com.boydti.fawe.bukkit.adapter.v1_13_1; -import com.sk89q.util.ReflectionUtil; import com.sk89q.worldedit.world.registry.BlockMaterial; - -import net.minecraft.server.v1_13_R2.*; +import net.minecraft.server.v1_13_R2.Block; +import net.minecraft.server.v1_13_R2.EnumPistonReaction; +import net.minecraft.server.v1_13_R2.IBlockData; +import net.minecraft.server.v1_13_R2.ITileEntity; +import net.minecraft.server.v1_13_R2.Material; import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData; public class BlockMaterial_1_13 implements BlockMaterial { @@ -22,7 +24,7 @@ public class BlockMaterial_1_13 implements BlockMaterial { this.defaultState = defaultState; this.material = defaultState.getMaterial(); this.craftBlockData = CraftBlockData.fromData(defaultState); - this.isTranslucent = ReflectionUtil.getField(Block.class, block, "n"); + this.isTranslucent = block.f(defaultState); //isSolid } public Block getBlock() { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java index 1d3b5fb53..d16684bcd 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java @@ -20,7 +20,6 @@ package com.boydti.fawe.bukkit.adapter.v1_13_1; import com.boydti.fawe.Fawe; -import com.boydti.fawe.object.collection.ObjObjMap; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; import com.sk89q.jnbt.Tag; @@ -33,42 +32,50 @@ import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.LazyBaseEntity; import com.sk89q.worldedit.internal.Constants; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.registry.state.*; +import com.sk89q.worldedit.registry.state.BooleanProperty; +import com.sk89q.worldedit.registry.state.DirectionalProperty; +import com.sk89q.worldedit.registry.state.EnumProperty; +import com.sk89q.worldedit.registry.state.IntegerProperty; +import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.Direction; -import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.*; +import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.registry.BlockMaterial; import net.minecraft.server.v1_13_R2.*; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.v1_13_R2.CraftChunk; import org.bukkit.craftbukkit.v1_13_R2.CraftServer; import org.bukkit.craftbukkit.v1_13_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock; import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData; import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.annotation.Nullable; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.function.Supplier; import java.util.logging.Level; +import java.util.logging.Logger; import java.util.stream.Collectors; import static com.google.common.base.Preconditions.checkNotNull; public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements BukkitImplAdapter{ - private final Logger logger = LoggerFactory.getLogger(getClass()); + private final Logger logger = Logger.getLogger(getClass().getCanonicalName()); private final Field nbtListTagListField; private final Method nbtCreateTagMethod; @@ -83,6 +90,9 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit // ------------------------------------------------------------------------ public Spigot_v1_13_R2() throws NoSuchFieldException, NoSuchMethodException { + // A simple test + CraftServer.class.cast(Bukkit.getServer()); + // The list of tags on an NBTTagList nbtListTagListField = NBTTagList.class.getDeclaredField("list"); nbtListTagListField.setAccessible(true); @@ -139,6 +149,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit @Nullable private static String getEntityId(Entity entity) { MinecraftKey minecraftkey = EntityTypes.getName(entity.getBukkitEntity().getHandle().P()); + return minecraftkey == null ? null : minecraftkey.toString(); } @@ -189,11 +200,6 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit return IRegistry.BLOCK.getOrDefault(new MinecraftKey(blockType.getNamespace(), blockType.getResource())); } - // ------------------------------------------------------------------------ - // Code that is less likely to break - // ------------------------------------------------------------------------ - - @SuppressWarnings("deprecation") @Override public BaseBlock getBlock(Location location) { checkNotNull(location); @@ -247,7 +253,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit nmsChunk.d(pos); // Force delete the old tile entity - CompoundTag nativeTag = state instanceof BaseBlock ? ((BaseBlock)state).getNbtData() : null; + CompoundTag nativeTag = state instanceof BaseBlock ? state.getNbtData() : null; if (nativeTag != null || existing instanceof TileEntityBlock) { nmsWorld.setTypeAndData(pos, blockData, 0); // remove tile @@ -348,7 +354,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit return Collections.emptyMap(); } if (block == null) { - logger.warn("Failed to find properties for " + blockType.getId()); + logger.warning("Failed to find properties for " + blockType.getId()); return Collections.emptyMap(); } Map> properties = Maps.newLinkedHashMap(); @@ -414,7 +420,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit try { return toNativeList((NBTTagList) foreign); } catch (Throwable e) { - logger.warn("Failed to convert NBTTagList", e); + logger.log(Level.WARNING, "Failed to convert NBTTagList", e); return new ListTag(ByteTag.class, new ArrayList()); } } else if (foreign instanceof NBTTagLong) { @@ -440,7 +446,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit * @throws IllegalArgumentException on error * @throws IllegalAccessException on error */ - public ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + private ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { List values = new ArrayList<>(); int type = foreign.d(); @@ -541,7 +547,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit @Override public void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData) { // TODO Auto-generated method stub - + } @Override @@ -557,6 +563,6 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit @Override public void sendFakeOP(Player player) { // TODO Auto-generated method stub - + } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/ArrayWrapper.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/ArrayWrapper.java index fc84afa67..d24b7cc19 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/ArrayWrapper.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/ArrayWrapper.java @@ -23,6 +23,7 @@ public final class ArrayWrapper { * * @param elements The elements of the array. */ + @SafeVarargs public ArrayWrapper(E... elements) { setArray(elements); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/FancyMessage.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/FancyMessage.java index 35045946e..22983d20a 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/FancyMessage.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/FancyMessage.java @@ -12,27 +12,17 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Consumer; import java.util.logging.Level; -import org.bukkit.Achievement; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Statistic; -import org.bukkit.Statistic.Type; import org.bukkit.command.CommandSender; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerialization; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; import static com.boydti.fawe.bukkit.chat.TextualComponent.rawText; @@ -271,162 +261,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< return this; } - /** - * Set the behavior of the current editing component to display information about an achievement when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

- * - * @param name The name of the achievement to display, excluding the "achievement." prefix. - * @return This builder instance. - */ - public FancyMessage achievementTooltip(final String name) { - onHover("show_achievement", new JsonString("achievement." + name)); - return this; - } - - /** - * Set the behavior of the current editing component to display information about an achievement when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

- * - * @param which The achievement to display. - * @return This builder instance. - */ - public FancyMessage achievementTooltip(final Achievement which) { - try { - Object achievement = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement", Achievement.class).invoke(null, which); - return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Achievement"), "name").get(achievement)); - } catch (IllegalAccessException e) { - Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e); - return this; - } catch (IllegalArgumentException e) { - Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e); - return this; - } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e); - return this; - } - } - - /** - * Set the behavior of the current editing component to display information about a parameterless statistic when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

- * - * @param which The statistic to display. - * @return This builder instance. - * @throws IllegalArgumentException If the statistic requires a parameter which was not supplied. - */ - public FancyMessage statisticTooltip(final Statistic which) { - Type type = which.getType(); - if (type != Type.UNTYPED) { - throw new IllegalArgumentException("That statistic requires an additional " + type + " parameter!"); - } - try { - Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSStatistic", Statistic.class).invoke(null, which); - return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic)); - } catch (IllegalAccessException e) { - Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e); - return this; - } catch (IllegalArgumentException e) { - Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e); - return this; - } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e); - return this; - } - } - - /** - * Set the behavior of the current editing component to display information about a statistic parameter with a material when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

- * - * @param which The statistic to display. - * @param item The sole material parameter to the statistic. - * @return This builder instance. - * @throws IllegalArgumentException If the statistic requires a parameter which was not supplied, or was supplied a parameter that was not required. - */ - public FancyMessage statisticTooltip(final Statistic which, Material item) { - Type type = which.getType(); - if (type == Type.UNTYPED) { - throw new IllegalArgumentException("That statistic needs no additional parameter!"); - } - if ((type == Type.BLOCK && item.isBlock()) || type == Type.ENTITY) { - throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!"); - } - try { - Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getMaterialStatistic", Statistic.class, Material.class).invoke(null, which, item); - return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic)); - } catch (IllegalAccessException e) { - Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e); - return this; - } catch (IllegalArgumentException e) { - Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e); - return this; - } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e); - return this; - } - } - - /** - * Set the behavior of the current editing component to display information about a statistic parameter with an entity type when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

- * - * @param which The statistic to display. - * @param entity The sole entity type parameter to the statistic. - * @return This builder instance. - * @throws IllegalArgumentException If the statistic requires a parameter which was not supplied, or was supplied a parameter that was not required. - */ - public FancyMessage statisticTooltip(final Statistic which, EntityType entity) { - Type type = which.getType(); - if (type == Type.UNTYPED) { - throw new IllegalArgumentException("That statistic needs no additional parameter!"); - } - if (type != Type.ENTITY) { - throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!"); - } - try { - Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getEntityStatistic", Statistic.class, EntityType.class).invoke(null, which, entity); - return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic)); - } catch (IllegalAccessException e) { - Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e); - return this; - } catch (IllegalArgumentException e) { - Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e); - return this; - } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e); - return this; - } - } - - /** - * Set the behavior of the current editing component to display information about an item when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

- * - * @param itemJSON A string representing the JSON-serialized NBT data tag of an {@link ItemStack}. - * @return This builder instance. - */ - public FancyMessage itemTooltip(final String itemJSON) { - onHover("show_item", new JsonString(itemJSON)); // Seems a bit hacky, considering we have a JSON object as a parameter - return this; - } - - /** - * Set the behavior of the current editing component to display information about an item when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

- * - * @param itemStack The stack for which to display information. - * @return This builder instance. - */ - public FancyMessage itemTooltip(final ItemStack itemStack) { - try { - Object nmsItem = Reflection.getMethod(Reflection.getOBCClass("inventory.CraftItemStack"), "asNMSCopy", ItemStack.class).invoke(null, itemStack); - return itemTooltip(Reflection.getMethod(Reflection.getNMSClass("ItemStack"), "save", Reflection.getNMSClass("NBTTagCompound")).invoke(nmsItem, Reflection.getNMSClass("NBTTagCompound").newInstance()).toString()); - } catch (Exception e) { - e.printStackTrace(); - return this; - } - } - /** * Set the behavior of the current editing component to display raw text when the client hovers over the text. *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

@@ -579,9 +413,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< * @return This builder instance. */ public FancyMessage translationReplacements(final FancyMessage... replacements) { - for (FancyMessage str : replacements) { - latest().translationReplacements.add(str); - } + Collections.addAll(latest().translationReplacements, replacements); dirty = true; @@ -873,6 +705,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< /** * Internally called method. Not for API consumption. */ + @NotNull public Iterator iterator() { return messageParts.iterator(); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/Reflection.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/Reflection.java index 17e5e4280..a60d4cdda 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/Reflection.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/Reflection.java @@ -40,10 +40,6 @@ public final class Reflection { */ public synchronized static String getVersion() { if (_versionString == null) { - if (Bukkit.getServer() == null) { - // The server hasn't started, static initializer call? - return null; - } String name = Bukkit.getServer().getClass().getPackage().getName(); _versionString = name.substring(name.lastIndexOf('.') + 1) + "."; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/TextualComponent.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/TextualComponent.java index e42b691bc..53365f433 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/TextualComponent.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/TextualComponent.java @@ -1,7 +1,6 @@ package com.boydti.fawe.bukkit.chat; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.HashMap; @@ -75,48 +74,6 @@ public abstract class TextualComponent implements Cloneable { throw new UnsupportedOperationException("This feature is only supported in snapshot releases."); } - /** - * Create a textual component representing a scoreboard value. - * The client will see their own score for the specified objective as the text represented by this component. - *

- * This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients. - *

- * - * @param scoreboardObjective The name of the objective for which to display the score. - * @return The text component representing the specified scoreboard score (for the viewing player), or {@code null} if an error occurs during - * JSON serialization. - */ - public static TextualComponent objectiveScore(String scoreboardObjective) { - return objectiveScore("*", scoreboardObjective); - } - - /** - * Create a textual component representing a scoreboard value. - * The client will see the score of the specified player for the specified objective as the text represented by this component. - * - *

This method is currently guaranteed to throw an {@code UnsupportedOperationException} - * as it is only supported on snapshot clients. - * - * @param playerName The name of the player whos score will be shown. If - * this string represents the single-character sequence - * "*", the viewing player's score will be displayed. - * Standard minecraft selectors (@a, @p, etc) - * are not supported. - * @param scoreboardObjective The name of the objective for - * which to display the score. - * @return The text component representing the specified scoreboard score - * for the specified player, or {@code null} if an error occurs during JSON serialization. - */ - public static TextualComponent objectiveScore(String playerName, String scoreboardObjective) { - throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE - // OVERLOADS documentation accordingly - - return new ComplexTextTypeComponent("score", ImmutableMap.builder() - .put("name", playerName) - .put("objective", scoreboardObjective) - .build()); - } - /** * Create a textual component representing a player name, retrievable by using a standard minecraft selector. * The client will see the players or entities captured by the specified selector as the text represented by this component. diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java index 1f49830de..30de5ffa0 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java @@ -4,13 +4,12 @@ import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.regions.general.CuboidRegionFilter; import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.math.BlockVector2; - -import java.util.ArrayDeque; -import java.util.Collection; import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.GriefPrevention; import org.bukkit.World; +import java.util.ArrayDeque; +import java.util.Collection; import static com.google.common.base.Preconditions.checkNotNull; @@ -23,7 +22,7 @@ public class GriefPreventionFilter extends CuboidRegionFilter { this.claims = TaskManager.IMP.sync(new RunnableVal>() { @Override public void run(Collection claims) { - this.value = new ArrayDeque(GriefPrevention.instance.dataStore.getClaims()); + this.value = new ArrayDeque<>(GriefPrevention.instance.dataStore.getClaims()); } }); this.world = world; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java index b195a9368..2f4443d81 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java @@ -7,7 +7,6 @@ import com.boydti.fawe.regions.general.CuboidRegionFilter; import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldguard.WorldGuard; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; @@ -65,4 +64,4 @@ public class WorldGuardFilter extends CuboidRegionFilter { ApplicableRegionSet set = manager.getApplicableRegions(regionRegion); return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__"); } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java index 53c0a9b70..48a79232e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java @@ -29,7 +29,7 @@ public class ATabCompleteListener implements Listener { Dispatcher dispatcher = CommandManager.getInstance().getDispatcher(); CommandMapping weCommand = dispatcher.get(label); if (weCommand != null) { - CommandSuggestionEvent event = new CommandSuggestionEvent(worldEdit.wrapCommandSender(sender), buffer.substring(index, buffer.length())); + CommandSuggestionEvent event = new CommandSuggestionEvent(worldEdit.wrapCommandSender(sender), buffer.substring(index)); worldEdit.getWorldEdit().getEventBus().post(event); List suggestions = event.getSuggestions(); if (suggestions != null && !suggestions.isEmpty()) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java index e175ff1d5..8d995846c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java @@ -10,22 +10,15 @@ import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.image.ImageViewer; -import com.sk89q.worldedit.*; +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.tool.BrushTool; import com.sk89q.worldedit.command.tool.InvalidToolBindException; import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; - -import java.util.ArrayDeque; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.Rotation; import org.bukkit.World; import org.bukkit.block.Block; @@ -48,6 +41,13 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.plugin.Plugin; +import java.util.ArrayDeque; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.UUID; + public class BukkitImageListener implements Listener { private Location mutable = new Location(Bukkit.getWorlds().get(0), 0, 0, 0); @@ -153,8 +153,7 @@ public class BukkitImageListener implements Listener { ImageViewer viewer = generator.getImageViewer(); if (!(viewer instanceof BukkitImageViewer)) return null; - BukkitImageViewer biv = (BukkitImageViewer) viewer; - return biv; + return (BukkitImageViewer) viewer; } private void handleInteract(PlayerEvent event, Entity entity, boolean primary) { @@ -189,7 +188,6 @@ public class BukkitImageListener implements Listener { return; } - if (tool == null) return; BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary(); Brush brush = context.getBrush(); if (brush == null) return; @@ -210,7 +208,7 @@ public class BukkitImageListener implements Listener { double zRat = Math.sin(yawRad) * a; BlockFace facing = itemFrame.getFacing(); - double thickness = 1/32d + 1/128d; + double thickness = 1/32D + 1/128D; double modX = facing.getModX(); double modZ = facing.getModZ(); double dx = source.getX() - target.getX() - modX * thickness; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java index 7f5ef82c5..cec672dd0 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java @@ -1,6 +1,5 @@ package com.boydti.fawe.bukkit.listener; -import com.boydti.fawe.FaweCache; import com.boydti.fawe.command.CFICommands; import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FawePlayer; @@ -15,30 +14,25 @@ import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.injector.netty.WirePacket; import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.BlockPosition; import com.comphenix.protocol.wrappers.ChunkCoordIntPair; import com.comphenix.protocol.wrappers.EnumWrappers; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.event.platform.BlockInteractEvent; import com.sk89q.worldedit.event.platform.Interaction; import com.sk89q.worldedit.extension.platform.PlatformManager; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import java.lang.reflect.InvocationTargetException; import java.util.List; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockTypes; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -70,7 +64,7 @@ public class CFIPacketListener implements Listener { Player plr = event.getPlayer(); BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint()); if (!sendBlockChange(plr, gen, pt, Interaction.HIT)) { - gen.setBlock(pt, EditSession.nullBlock); + gen.setBlock(pt, BlockTypes.AIR.getDefaultState()); } } catch (WorldEditException e) { e.printStackTrace(); @@ -89,7 +83,7 @@ public class CFIPacketListener implements Listener { EnumWrappers.Hand enumHand = hands.isEmpty() ? EnumWrappers.Hand.MAIN_HAND : hands.get(0); PlayerInventory inv = plr.getInventory(); ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand(); - if (hand != null && hand.getType().isBlock()) { + if (hand.getType().isBlock()) { Material type = hand.getType(); switch (type) { case AIR: @@ -287,8 +281,7 @@ public class CFIPacketListener implements Listener { BlockPosition loc = position.readSafely(0); if (loc == null) return null; BlockVector3 origin = generator.getOrigin().toBlockPoint(); - BlockVector3 pt = BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ()); - return pt; + return BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ()); } private void handleBlockEvent(PacketEvent event, boolean relative, RunnableVal3 task) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java index c875f6812..2c1a58fcd 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java @@ -1,8 +1,8 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMask; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.wasteofplastic.askyblock.ASkyBlockAPI; import com.wasteofplastic.askyblock.Island; import org.bukkit.Location; @@ -12,13 +12,9 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; public class ASkyBlockHook extends BukkitMaskManager implements Listener { - FaweBukkit plugin; - Plugin aSkyBlock; - public ASkyBlockHook(final Plugin aSkyBlock, final FaweBukkit p3) { + public ASkyBlockHook(final Plugin aSkyBlock) { super(aSkyBlock.getName()); - this.aSkyBlock = aSkyBlock; - this.plugin = p3; } @@ -33,8 +29,6 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener { Island island = ASkyBlockAPI.getInstance().getIslandAt(location); if (island != null && isAllowed(player, island, type)) { - int minX = island.getMinProtectedX(); - int minZ = island.getMinProtectedZ(); World world = location.getWorld(); Location center = island.getCenter(); @@ -42,7 +36,7 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener { Location pos2 = center.add(center.subtract(pos1)); pos2.setY(255); - return new BukkitMask(pos1, pos2, "ISLAND: " + minX + "," + minZ) { + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed((Player) player.parent, island, type); @@ -52,4 +46,4 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener { return null; } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java deleted file mode 100644 index 54e9f0bc9..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.boydti.fawe.bukkit.regions; - -import com.boydti.fawe.regions.FaweMask; -import com.sk89q.worldedit.math.BlockVector3; - -import org.bukkit.Location; - -public class BukkitMask extends FaweMask { - - public BukkitMask(Location pos1, Location pos2) { - this(pos1, pos2, null); - } - - public BukkitMask(Location pos1, Location pos2, String name) { - super(BlockVector3.at(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), BlockVector3.at(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()), name); - } -} \ No newline at end of file diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java index f460862f7..723a6a838 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java @@ -1,11 +1,12 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.regions.FaweMask; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.ps.PS; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -13,18 +14,13 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; public class FactionsFeature extends BukkitMaskManager implements Listener { - FaweBukkit plugin; - Plugin factions; - public FactionsFeature(final Plugin factionsPlugin, final FaweBukkit p3) { + public FactionsFeature(final Plugin factionsPlugin) { super(factionsPlugin.getName()); - this.factions = factionsPlugin; - this.plugin = p3; - BoardColl.get(); } @Override - public BukkitMask getMask(final FawePlayer fp, MaskType type) { + public FaweMask getMask(final FawePlayer fp, MaskType type) { final Player player = fp.parent; final Location loc = player.getLocation(); final PS ps = PS.valueOf(loc); @@ -36,25 +32,14 @@ public class FactionsFeature extends BukkitMaskManager implements Listener { final Chunk chunk = loc.getChunk(); final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "CHUNK:" + loc.getChunk().getX() + "," + loc.getChunk().getZ(); - } - }; + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); } - } - else if (fac.getOnlinePlayers().contains(player)) { - if (fac.getComparisonName().equals("wilderness") == false) { + } else if (fac.getOnlinePlayers().contains(player)) { + if (!fac.getComparisonName().equals("wilderness")) { final Chunk chunk = loc.getChunk(); final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "CHUNK:" + loc.getChunk().getX() + "," + loc.getChunk().getZ(); - } - }; + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java index 4eab92792..eafcb7634 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java @@ -1,13 +1,11 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; -import com.boydti.fawe.util.MainUtil; +import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.util.Perm; import com.massivecraft.factions.FLocation; -import java.lang.reflect.Method; -import java.util.List; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -15,19 +13,21 @@ import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; +import java.lang.reflect.Method; +import java.util.List; + public class FactionsOneFeature extends BukkitMaskManager implements Listener { - private final Class clazzBoard; private final Method methodGetFactionAt; - public FactionsOneFeature(final Plugin factionsPlugin, final FaweBukkit p3) throws Throwable { + public FactionsOneFeature(final Plugin factionsPlugin) throws Throwable { super(factionsPlugin.getName()); - this.clazzBoard = Class.forName("com.massivecraft.factions.Board"); + Class clazzBoard = Class.forName("com.massivecraft.factions.Board"); this.methodGetFactionAt = clazzBoard.getDeclaredMethod("getFactionAt", FLocation.class); } @Override - public BukkitMask getMask(final FawePlayer fp, MaskType type) { + public FaweMask getMask(final FawePlayer fp, MaskType type) { final Player player = fp.parent; final Chunk chunk = player.getLocation().getChunk(); final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness"); @@ -40,13 +40,12 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener { if (this.isAdded(locs, world, player, perm, type)) { boolean hasPerm = true; - RegionWrapper chunkSelection; while (hasPerm && (count > 0)) { count--; hasPerm = false; - chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ); + RegionWrapper chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ); if (this.isAdded(chunkSelection, world, player, perm, type)) { locs = new RegionWrapper(locs.minX, locs.maxX + 1, locs.minZ, locs.maxZ); @@ -77,12 +76,7 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener { final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4); final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4)); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "CHUNK:" + pos1.getChunk().getX() + "," + pos1.getChunk().getZ(); - } - }; + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); } return null; } @@ -112,7 +106,7 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener { } return true; } catch (Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); return false; } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java index 29451faa5..12f10ae66 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java @@ -3,10 +3,12 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; +import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.util.Perm; import com.massivecraft.factions.Board; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -23,7 +25,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener { } @Override - public BukkitMask getMask(final FawePlayer fp, MaskType type) { + public FaweMask getMask(final FawePlayer fp, MaskType type) { final Player player = fp.parent; final Chunk chunk = player.getLocation().getChunk(); final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness"); @@ -36,13 +38,12 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener { if (this.isAdded(locs, world, player, perm, type)) { boolean hasPerm = true; - RegionWrapper chunkSelection; while (hasPerm && (count > 0)) { count--; hasPerm = false; - chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ); + RegionWrapper chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ); if (this.isAdded(chunkSelection, world, player, perm, type)) { locs = new RegionWrapper(locs.minX, locs.maxX + 1, locs.minZ, locs.maxZ); @@ -73,12 +74,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener { final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4); final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4)); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "CHUNK:" + pos1.getChunk().getX() + "," + pos1.getChunk().getZ(); - } - }; + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); } return null; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java index e1aa7bbc9..6e9b47a9d 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java @@ -50,33 +50,27 @@ public class FreeBuildRegion extends BukkitMaskManager { currRegList.add(listener); } if (currRegList.isEmpty()) return null; - RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[currRegList.size()]); + RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]); World bukkitWorld = player.parent.getWorld(); AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld); - BlockVector3 vec1 = BlockVector3.at(0, 0, 0); - BlockVector3 vec2 = vec1; - Location pos1 = BukkitAdapter.adapt(bukkitWorld, vec1); - Location pos2 = BukkitAdapter.adapt(bukkitWorld, vec2); + Location pos1 = BukkitAdapter.adapt(bukkitWorld, BlockVector3.ZERO); + Location pos2 = BukkitAdapter.adapt(bukkitWorld, BlockVector3.ZERO); AsyncBlock block = new AsyncBlock(asyncWorld, new NullFaweQueue(asyncWorld.getWorldName(), BlockTypes.STONE.getDefaultState()), 0, 0, 0); BlockBreakEvent event = new BlockBreakEvent(block, player.parent); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "freebuild-global"; - } + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { - @Override + @Override public boolean isValid(FawePlayer player, MaskType type) { return bukkitWorld == ((FawePlayer)player).parent.getWorld() && type == MaskType.MEMBER; } @Override public Region getRegion() { - return new CuboidRegion(vec1, vec2) { + return new CuboidRegion(BlockVector3.ZERO, BlockVector3.ZERO) { @Override public boolean contains(int x, int z) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java index 8832ec90b..6b987df14 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java @@ -1,9 +1,10 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.filter.GriefPreventionFilter; import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.general.RegionFilter; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.GriefPrevention; import org.bukkit.Bukkit; @@ -14,13 +15,9 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; public class GriefPreventionFeature extends BukkitMaskManager implements Listener { - FaweBukkit plugin; - Plugin griefprevention; - public GriefPreventionFeature(final Plugin griefpreventionPlugin, final FaweBukkit p3) { + public GriefPreventionFeature(final Plugin griefpreventionPlugin) { super(griefpreventionPlugin.getName()); - this.griefprevention = griefpreventionPlugin; - this.plugin = p3; } public boolean isAllowed(Player player, Claim claim, MaskType type) { @@ -28,21 +25,16 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene } @Override - public BukkitMask getMask(final FawePlayer fp, MaskType type) { + public FaweMask getMask(final FawePlayer fp, MaskType type) { final Player player = fp.parent; final Location location = player.getLocation(); final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null); if (claim != null) { - final String uuid = player.getUniqueId().toString(); if (isAllowed(player, claim, type)) { claim.getGreaterBoundaryCorner().getBlockX(); final Location pos1 = new Location(location.getWorld(), claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ()); final Location pos2 = new Location(location.getWorld(), claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ()); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "CLAIM:" + claim.toString(); - } + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { @Override public boolean isValid(FawePlayer player, MaskType type) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java index 7b0af05b5..d67f9a919 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java @@ -43,7 +43,7 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener if (isAllowed(player, myField, type, member)) { BlockVector3 pos1 = BlockVector3.at(myField.getMinx(), myField.getMiny(), myField.getMinz()); BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz()); - return new FaweMask(pos1, pos2, "FIELD: " + myField) { + return new FaweMask(pos1, pos2) { @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed((Player) player.parent, myField, type, fp.hasPermission("fawe.preciousstones.member")); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java index 024fa92f2..398be6d63 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java @@ -5,6 +5,8 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence; import com.bekvon.bukkit.residence.protection.CuboidArea; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.regions.FaweMask; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -26,7 +28,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener { } @Override - public BukkitMask getMask(final FawePlayer fp, final MaskType type) { + public FaweMask getMask(final FawePlayer fp, final MaskType type) { final Player player = fp.parent; final Location location = player.getLocation(); ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location); @@ -40,13 +42,8 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener { final Location pos1 = area.getLowLoc(); final Location pos2 = area.getHighLoc(); final ClaimedResidence finalResidence = residence; - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "RESIDENCE: " + finalResidence.getName(); - } - - @Override + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { + @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed((Player) player.parent, finalResidence, type); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java index 587dda379..06a4476d1 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java @@ -2,9 +2,11 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.regions.FaweMask; import com.palmergames.bukkit.towny.Towny; import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; import com.palmergames.bukkit.towny.object.*; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -53,7 +55,7 @@ public class TownyFeature extends BukkitMaskManager implements Listener { } @Override - public BukkitMask getMask(final FawePlayer fp) { + public FaweMask getMask(final FawePlayer fp) { final Player player = fp.parent; final Location location = player.getLocation(); try { @@ -71,12 +73,7 @@ public class TownyFeature extends BukkitMaskManager implements Listener { final Chunk chunk = location.getChunk(); final Location pos1 = new Location(location.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final Location pos2 = new Location(location.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "PLOT:" + location.getChunk().getX() + "," + location.getChunk().getZ(); - } - + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed((Player) player.parent, myplot); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java index cb7a91675..887c47a01 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java @@ -1,14 +1,13 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.FaweAPI; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.filter.WorldGuardFilter; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.general.RegionFilter; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Polygonal2DRegion; @@ -18,7 +17,11 @@ import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.managers.RegionManager; -import com.sk89q.worldguard.protection.regions.*; +import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion; +import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; +import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion; +import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import com.sk89q.worldguard.protection.regions.RegionContainer; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -26,14 +29,14 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; public class Worldguard extends BukkitMaskManager implements Listener { - WorldGuardPlugin worldguard; + private WorldGuardPlugin worldguard; FaweBukkit plugin; private WorldGuardPlugin getWorldGuard() { final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard"); // WorldGuard may not be loaded - if ((plugin == null) || !(plugin instanceof WorldGuardPlugin)) { + if (!(plugin instanceof WorldGuardPlugin)) { return null; // Maybe you want throw an exception instead } @@ -46,13 +49,13 @@ public class Worldguard extends BukkitMaskManager implements Listener { this.plugin = p3; } - public ProtectedRegion getRegion(final com.sk89q.worldguard.LocalPlayer player, final Location loc) { + public ProtectedRegion getRegion(final LocalPlayer player, final Location location) { RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); if (container == null) { System.out.println("Region capability is not enabled for WorldGuard."); return null; } - RegionManager manager = container.get(FaweAPI.getWorld(loc.getWorld().getName())); + RegionManager manager = container.get(BukkitAdapter.adapt(location.getWorld())); if (manager == null) { System.out.println("Region capability is not enabled for that world."); return null; @@ -61,7 +64,7 @@ public class Worldguard extends BukkitMaskManager implements Listener { if (global != null && isAllowed(player, global)) { return global; } - final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ())); + final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(location.getX(), location.getY(), location.getZ())); for (final ProtectedRegion region : regions) { if (isAllowed(player, region)) { return region; @@ -93,7 +96,7 @@ public class Worldguard extends BukkitMaskManager implements Listener { @Override public FaweMask getMask(FawePlayer fp, MaskType type) { final Player player = fp.parent; - final com.sk89q.worldguard.LocalPlayer localplayer = this.worldguard.wrapPlayer(player); + final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); final Location location = player.getLocation(); final ProtectedRegion myregion = this.getRegion(localplayer, location); if (myregion != null) { @@ -107,7 +110,7 @@ public class Worldguard extends BukkitMaskManager implements Listener { pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ()); pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ()); } else { - return new FaweMask(adapt(myregion), myregion.getId()) { + return new FaweMask(adapt(myregion)) { @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion); @@ -115,20 +118,15 @@ public class Worldguard extends BukkitMaskManager implements Listener { }; } } - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return myregion.getId(); - } + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { - @Override + @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion); } }; - } else { - return null; } + return null; } @Override diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java index 3f3f1a842..333728814 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java @@ -37,7 +37,7 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener { final RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); final RegionManager manager = container.get(fp.getWorld()); - return new FaweMask(new ManagerRegion(manager, localplayer), null) { + return new FaweMask(new ManagerRegion(manager, localplayer)) { @Override public boolean isValid(FawePlayer player, MaskType type) { // We rely on the region mask instead of this diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java index 1079f8c2d..43a1d5968 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java @@ -1,11 +1,11 @@ package com.boydti.fawe.bukkit.util; -import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.ReflectionUtils; -import java.lang.reflect.Method; import org.bukkit.Bukkit; import org.bukkit.Server; +import java.lang.reflect.Method; + public class BukkitReflectionUtils { /** * prefix of bukkit classes @@ -15,49 +15,33 @@ public class BukkitReflectionUtils { * prefix of minecraft classes */ private static volatile String preClassM = null; - /** - * boolean value, TRUE if server uses forge or MCPC+ - */ - private static boolean forge = false; /** * check server version and class names */ public static void init() { - if (Bukkit.getServer() != null) { - if (Bukkit.getVersion().contains("MCPC") || Bukkit.getVersion().contains("Forge")) { - forge = true; - } - final Server server = Bukkit.getServer(); - final Class bukkitServerClass = server.getClass(); - String[] pas = bukkitServerClass.getName().split("\\."); + final Server server = Bukkit.getServer(); + final Class bukkitServerClass = server.getClass(); + String[] pas = bukkitServerClass.getName().split("\\."); + if (pas.length == 5) { + final String verB = pas[3]; + preClassB = "org.bukkit.craftbukkit." + verB; + } + try { + final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle"); + final Object handle = getHandle.invoke(server); + final Class handleServerClass = handle.getClass(); + pas = handleServerClass.getName().split("\\."); if (pas.length == 5) { - final String verB = pas[3]; - preClassB = "org.bukkit.craftbukkit." + verB; - } - try { - final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle"); - final Object handle = getHandle.invoke(server); - final Class handleServerClass = handle.getClass(); - pas = handleServerClass.getName().split("\\."); - if (pas.length == 5) { - final String verM = pas[3]; - preClassM = "net.minecraft.server." + verM; - } - } catch (final Exception ignored) { - MainUtil.handleError(ignored); + final String verM = pas[3]; + preClassM = "net.minecraft.server." + verM; } + } catch (final Exception e) { + e.printStackTrace(); } } - /** - * @return true if server has forge classes - */ - public static boolean isForge() { - return forge; - } - /** * Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace * {nm} to net.minecraft @@ -90,18 +74,6 @@ public class BukkitReflectionUtils { return ReflectionUtils.getClass(className); } - public static Class getUtilClass(final String name) { - try { - return Class.forName(name); //Try before 1.8 first - } catch (final ClassNotFoundException ex) { - try { - return Class.forName("net.minecraft.util." + name); //Not 1.8 - } catch (final ClassNotFoundException ex2) { - return null; - } - } - } - public static String getVersion() { final String packageName = Bukkit.getServer().getClass().getPackage().getName(); return packageName.substring(packageName.lastIndexOf('.') + 1); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java index 12de1f9ec..37d8722ba 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java @@ -4,6 +4,7 @@ import com.boydti.fawe.util.TaskManager; import org.apache.commons.lang.mutable.MutableInt; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; public class BukkitTaskMan extends TaskManager { @@ -14,44 +15,35 @@ public class BukkitTaskMan extends TaskManager { } @Override - public int repeat(final Runnable r, final int interval) { - return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, r, interval, interval); + public int repeat(@NotNull final Runnable runnable, final int interval) { + return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, runnable, interval, interval); } @Override - public int repeatAsync(final Runnable r, final int interval) { - return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, r, interval, interval); + public int repeatAsync(@NotNull final Runnable runnable, final int interval) { + return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, runnable, interval, interval); } public MutableInt index = new MutableInt(0); @Override - public void async(final Runnable r) { - if (r == null) { - return; - } - this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, r).getTaskId(); + public void async(@NotNull final Runnable runnable) { + this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, runnable).getTaskId(); } @Override - public void task(final Runnable r) { - if (r == null) { - return; - } - this.plugin.getServer().getScheduler().runTask(this.plugin, r).getTaskId(); + public void task(@NotNull final Runnable runnable) { + this.plugin.getServer().getScheduler().runTask(this.plugin, runnable).getTaskId(); } @Override - public void later(final Runnable r, final int delay) { - if (r == null) { - return; - } - this.plugin.getServer().getScheduler().runTaskLater(this.plugin, r, delay).getTaskId(); + public void later(@NotNull final Runnable runnable, final int delay) { + this.plugin.getServer().getScheduler().runTaskLater(this.plugin, runnable, delay).getTaskId(); } @Override - public void laterAsync(final Runnable r, final int delay) { - this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, r, delay); + public void laterAsync(@NotNull final Runnable runnable, final int delay) { + this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, runnable, delay); } @Override diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java index 28015ebb0..c06d53497 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java @@ -2,20 +2,20 @@ package com.boydti.fawe.bukkit.util; import com.boydti.fawe.bukkit.v0.BukkitQueue_0; import com.boydti.fawe.util.ReflectionUtils; + import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.Tag; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import org.bukkit.inventory.ItemStack; + import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.lang.reflect.Method; -import org.bukkit.inventory.ItemStack; public class ItemUtil { - private final Class classCraftItemStack; private final Method methodAsNMSCopy; - private final Class classNMSItem; private final Method methodGetTag; private final Method methodHasTag; private final Method methodSetTag; @@ -25,8 +25,8 @@ public class ItemUtil { private SoftReference>> hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>()); public ItemUtil() throws Exception { - this.classCraftItemStack = BukkitReflectionUtils.getCbClass("inventory.CraftItemStack"); - this.classNMSItem = BukkitReflectionUtils.getNmsClass("ItemStack"); + Class classCraftItemStack = BukkitReflectionUtils.getCbClass("inventory.CraftItemStack"); + Class classNMSItem = BukkitReflectionUtils.getNmsClass("ItemStack"); this.methodAsNMSCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class)); this.methodHasTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("hasTag")); this.methodGetTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("getTag")); @@ -61,7 +61,7 @@ public class ItemUtil { Int2ObjectOpenHashMap> map = hashToNMSTag.get(); if (map == null) { map = new Int2ObjectOpenHashMap<>(); - hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>(map)); + hashToNMSTag = new SoftReference<>(new Int2ObjectOpenHashMap<>(map)); } WeakReference nativeTagRef = map.get(nmsTag.hashCode()); if (nativeTagRef != null) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitChunk_All.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitChunk_All.java index f9cc87dc6..f06b31a1b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitChunk_All.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitChunk_All.java @@ -334,7 +334,7 @@ public class BukkitChunk_All extends IntFaweChunk { index = 0; } } catch (final Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } } while (System.currentTimeMillis() - start < recommended); if (more || place) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java index bcb83b6cd..3ea479f8e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java @@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.bukkit.BukkitPlayer; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.util.BukkitReflectionUtils; -import com.boydti.fawe.example.IntFaweChunk; import com.boydti.fawe.example.NMSMappedFaweQueue; import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FawePlayer; @@ -22,16 +21,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.world.biome.BiomeType; -import java.io.File; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - import com.sk89q.worldedit.world.block.BlockState; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -46,6 +35,12 @@ import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.WorldInitEvent; import org.bukkit.plugin.Plugin; +import java.io.File; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.concurrent.ConcurrentHashMap; + public abstract class BukkitQueue_0 extends NMSMappedFaweQueue implements Listener { protected static boolean PAPER = true; @@ -259,7 +254,7 @@ public abstract class BukkitQueue_0 extends NMSMa } public World createWorld(final WorldCreator creator) { - World world = TaskManager.IMP.sync(new RunnableVal() { + return TaskManager.IMP.sync(new RunnableVal() { @Override public void run(World value) { disableChunkLoad = true; @@ -267,7 +262,6 @@ public abstract class BukkitQueue_0 extends NMSMa disableChunkLoad = false; } }); - return world; } @Override @@ -289,8 +283,7 @@ public abstract class BukkitQueue_0 extends NMSMa @Override public boolean regenerateChunk(World world, int x, int z, BiomeType biome, Long seed) { if (!keepLoaded.isEmpty()) keepLoaded.remove(MathMan.pairInt(x, z)); - boolean result = world.regenerateChunk(x, z); - return result; + return world.regenerateChunk(x, z); } @Override diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java index 57147096d..b027a7008 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java @@ -11,20 +11,12 @@ import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.SetQueue; import com.boydti.fawe.util.TaskManager; + import com.google.common.collect.MapMaker; import com.sk89q.jnbt.CompoundTag; -import java.io.File; -import java.io.RandomAccessFile; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayDeque; -import java.util.Map; -import java.util.concurrent.ConcurrentMap; - import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; import org.bukkit.Chunk; import org.bukkit.ChunkSnapshot; @@ -33,6 +25,14 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; +import java.io.File; +import java.io.RandomAccessFile; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayDeque; +import java.util.Map; +import java.util.concurrent.ConcurrentMap; + public class BukkitQueue_All extends BukkitQueue_0 { private ConcurrentMap chunkCache = new MapMaker() @@ -78,15 +78,6 @@ public class BukkitQueue_All extends BukkitQueue_0 classRegionFileCache; - private static Class classRegionFile; - private static Class classCraftChunk; - private static Class classCraftWorld; - private static Class classNMSChunk; - private static Class classNMSWorld; - private static Class classChunkProviderServer; - private static Class classIChunkLoader; - private static Class classChunkRegionLoader; - private static Class classIChunkProvider; private static Method methodGetHandleChunk; private static Method methodGetHandleWorld; private static Method methodFlush; @@ -100,15 +91,15 @@ public class BukkitQueue_All extends BukkitQueue_0 classRegionFile = BukkitReflectionUtils.getNmsClass("RegionFile"); + Class classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk"); + Class classNMSChunk = BukkitReflectionUtils.getNmsClass("Chunk"); + Class classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld"); + Class classNMSWorld = BukkitReflectionUtils.getNmsClass("World"); + Class classChunkProviderServer = BukkitReflectionUtils.getNmsClass("ChunkProviderServer"); + Class classIChunkProvider = BukkitReflectionUtils.getNmsClass("IChunkProvider"); + Class classIChunkLoader = BukkitReflectionUtils.getNmsClass("IChunkLoader"); + Class classChunkRegionLoader = BukkitReflectionUtils.getNmsClass("ChunkRegionLoader"); methodGetHandleChunk = ReflectionUtils.setAccessible(classCraftChunk.getDeclaredMethod("getHandle")); methodGetHandleWorld = ReflectionUtils.setAccessible(classCraftWorld.getDeclaredMethod("getHandle")); @@ -120,8 +111,8 @@ public class BukkitQueue_All extends BukkitQueue_0 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) { - for (Entity ent : world.getEntities()) { - if (ent.getType() == EntityType.FIREWORK) { - Vector velocity = ent.getVelocity(); - double vertical = Math.abs(velocity.getY()); - if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) { - Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation()); - ent.remove(); - } + if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) { + for (Entity ent : world.getEntities()) { + if (ent.getType() == EntityType.FIREWORK) { + Vector velocity = ent.getVelocity(); + double vertical = Math.abs(velocity.getY()); + if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) { + Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation()); + ent.remove(); } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitChunk_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitChunk_1_13.java index 2ccfa8b5d..a023fc927 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitChunk_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitChunk_1_13.java @@ -284,7 +284,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk { copy.sectionPalettes[i] = copy(current); } } catch (Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } } return copy; @@ -296,7 +296,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk { @Override public Chunk getNewChunk() { - return ((BukkitQueue_1_13) getParent()).getWorld().getChunkAt(getX(), getZ()); + return getParent().getWorld().getChunkAt(getX(), getZ()); } public void optimize() { @@ -348,8 +348,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk { // Remove entities HashSet entsToRemove = this.getEntityRemoves(); if (!entsToRemove.isEmpty()) { - for (int i = 0; i < entities.length; i++) { - Collection ents = entities[i]; + for (Collection ents : entities) { if (!ents.isEmpty()) { Iterator iter = ents.iterator(); while (iter.hasNext()) { @@ -445,13 +444,11 @@ public class BukkitChunk_1_13 extends IntFaweChunk { UUID uuid = entity.getUniqueID(); entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits())); entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits())); - if (nativeTag != null) { - NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_13.fromNative(nativeTag); - for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { - tag.remove(name); - } - entity.f(tag); + NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_13.fromNative(nativeTag); + for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { + tag.remove(name); } + entity.f(tag); entity.setLocation(x, y, z, yaw, pitch); synchronized (BukkitQueue_0.class) { nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM); @@ -547,9 +544,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk { // Trim tiles HashMap toRemove = null; if (!tiles.isEmpty()) { - Iterator> iterator = tiles.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry tile = iterator.next(); + for (Map.Entry tile : tiles.entrySet()) { BlockPosition pos = tile.getKey(); int lx = pos.getX() & 15; int ly = pos.getY(); @@ -625,8 +620,8 @@ public class BukkitChunk_1_13 extends IntFaweChunk { getParent().getChangeTask().run(copy, this); } } catch (Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } return this; } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java index 2c51c965e..39a82d01a 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java @@ -1,6 +1,5 @@ package com.boydti.fawe.bukkit.v1_13; -import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.bukkit.BukkitPlayer; import com.boydti.fawe.bukkit.adapter.v1_13_1.BlockMaterial_1_13; @@ -14,10 +13,9 @@ import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.brush.visualization.VisualChunk; import com.boydti.fawe.object.visitor.FaweChunkVisitor; -import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; -import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.TaskManager; + import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockID; @@ -25,32 +23,7 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; -import net.minecraft.server.v1_13_R2.BiomeBase; -import net.minecraft.server.v1_13_R2.Block; -import net.minecraft.server.v1_13_R2.BlockPosition; -import net.minecraft.server.v1_13_R2.ChunkProviderServer; -import net.minecraft.server.v1_13_R2.ChunkSection; -import net.minecraft.server.v1_13_R2.DataBits; -import net.minecraft.server.v1_13_R2.DataPalette; -import net.minecraft.server.v1_13_R2.DataPaletteBlock; -import net.minecraft.server.v1_13_R2.DataPaletteHash; -import net.minecraft.server.v1_13_R2.DataPaletteLinear; -import net.minecraft.server.v1_13_R2.Entity; -import net.minecraft.server.v1_13_R2.EntityPlayer; -import net.minecraft.server.v1_13_R2.EnumSkyBlock; -import net.minecraft.server.v1_13_R2.GameProfileSerializer; -import net.minecraft.server.v1_13_R2.IBlockData; -import net.minecraft.server.v1_13_R2.NBTTagCompound; -import net.minecraft.server.v1_13_R2.Packet; -import net.minecraft.server.v1_13_R2.PacketDataSerializer; -import net.minecraft.server.v1_13_R2.PacketPlayOutMultiBlockChange; -import net.minecraft.server.v1_13_R2.PlayerChunk; -import net.minecraft.server.v1_13_R2.PlayerChunkMap; -import net.minecraft.server.v1_13_R2.RegistryID; -import net.minecraft.server.v1_13_R2.TileEntity; -import net.minecraft.server.v1_13_R2.WorldChunkManager; -import net.minecraft.server.v1_13_R2.WorldData; -import net.minecraft.server.v1_13_R2.WorldServer; +import net.minecraft.server.v1_13_R2.*; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.craftbukkit.v1_13_R2.CraftChunk; @@ -64,51 +37,34 @@ import java.util.Arrays; import java.util.Collection; import java.util.Map; import java.util.concurrent.atomic.LongAdder; -import java.util.function.Supplier; public class BukkitQueue_1_13 extends BukkitQueue_0 { protected final static Field fieldBits; - protected final static Field fieldPalette; - protected final static Field fieldSize; + final static Field fieldPalette; + final static Field fieldSize; - protected final static Field fieldHashBlocks; - protected final static Field fieldLinearBlocks; - protected final static Field fieldHashIndex; - protected final static Field fieldRegistryb; - protected final static Field fieldRegistryc; - protected final static Field fieldRegistryd; - protected final static Field fieldRegistrye; - protected final static Field fieldRegistryf; + final static Field fieldHashBlocks; + final static Field fieldLinearBlocks; + private final static Field fieldHashIndex; + final static Field fieldRegistryb; + final static Field fieldRegistryc; + final static Field fieldRegistryd; + final static Field fieldRegistrye; + final static Field fieldRegistryf; - protected final static Field fieldLinearIndex; - protected final static Field fieldDefaultBlock; + final static Field fieldLinearIndex; + final static Field fieldDefaultBlock; - protected final static Field fieldFluidCount; - protected final static Field fieldTickingBlockCount; - protected final static Field fieldNonEmptyBlockCount; - protected final static Field fieldSection; - protected final static Field fieldLiquidCount; - protected final static Field fieldEmittedLight; - protected final static Field fieldSkyLight; + private final static Field fieldFluidCount; + final static Field fieldTickingBlockCount; + final static Field fieldNonEmptyBlockCount; + final static Field fieldSection; + final static Field fieldLiquidCount; + private final static ChunkSection emptySection; - -// protected final static Field fieldBiomes; - - protected final static Field fieldChunkGenerator; - protected final static Field fieldSeed; -// protected final static Field fieldBiomeCache; -// protected final static Field fieldBiomes2; - protected final static Field fieldGenLayer1; - protected final static Field fieldGenLayer2; - protected final static Field fieldSave; -// protected final static MutableGenLayer genLayer; - protected final static ChunkSection emptySection; - -// protected static final Method methodResize; - - protected final static Field fieldDirtyCount; - protected final static Field fieldDirtyBits; + private final static Field fieldDirtyCount; + private final static Field fieldDirtyBits; static { try { @@ -116,12 +72,8 @@ public class BukkitQueue_1_13 extends BukkitQueue_0() { -// @Override -// public void run(Object value) { -// try { -// Field field = CraftServer.class.getDeclaredField("worlds"); -// field.setAccessible(true); -// Map existing = (Map) field.get(server); -// if (!existing.getClass().getName().contains("SynchronizedMap")) { -// field.set(server, Collections.synchronizedMap(existing)); -// } -// } catch (Throwable e) { -// e.printStackTrace(); -// } -// } -// }); -// if (generator == null) { -// generator = server.getGenerator(name); -// } -// int dimension = 10 + console.worlds.size(); -// boolean used = false; -// do { -// for (final WorldServer ws : console.worlds) { -// used = (ws.dimension == dimension); -// if (used) { -// ++dimension; -// break; -// } -// } -// } while (used); -// final boolean hardcore = false; -// final IDataManager sdm = new ServerNBTManager(server.getWorldContainer(), name, true, server.getHandle().getServer().dataConverterManager); -// WorldData worlddata = sdm.getWorldData(); -// final WorldSettings worldSettings; -// if (worlddata == null) { -// worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById(server.getDefaultGameMode().getValue()), generateStructures, hardcore, type); -// worldSettings.setGeneratorSettings(creator.generatorSettings()); -// worlddata = new WorldData(worldSettings, name); -// } else { -// worldSettings = null; -// } -// worlddata.checkName(name); -// final WorldServer internal = (WorldServer)new WorldServer(console, sdm, worlddata, dimension, console.methodProfiler, creator.environment(), generator).b(); -// startSet(true); // Temporarily allow async chunk load since the world isn't added yet -// if (worldSettings != null) { -// internal.a(worldSettings); -// } -// endSet(true); -// internal.scoreboard = server.getScoreboardManager().getMainScoreboard().getHandle(); -// internal.tracker = new EntityTracker(internal); -// internal.addIWorldAccess(new WorldManager(console, internal)); -// internal.worldData.setDifficulty(EnumDifficulty.EASY); -// internal.setSpawnFlags(true, true); -// if (generator != null) { -// internal.getWorld().getPopulators().addAll(generator.getDefaultPopulators(internal.getWorld())); -// } -// // Add the world -// return TaskManager.IMP.sync(new RunnableVal() { -// @Override -// public void run(World value) { -// console.worlds.add(internal); -// server.getPluginManager().callEvent(new WorldInitEvent(internal.getWorld())); -// server.getPluginManager().callEvent(new WorldLoadEvent(internal.getWorld())); -// this.value = internal.getWorld(); -// } -// }); -// } - @Override public int getCombinedId4Data(ChunkSection lastSection, int x, int y, int z) { DataPaletteBlock dataPalette = lastSection.getBlocks(); @@ -679,7 +476,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0() { - @Override - public Object get() { - try { - int dirtyBits = fieldDirtyBits.getInt(playerChunk); - if (dirtyBits == 0) { - ((CraftWorld) getWorld()).getHandle().getPlayerChunkMap().a(playerChunk); - } - if (mask == 0) { - dirtyBits = 65535; - } else { - dirtyBits |= mask; - } - - fieldDirtyBits.set(playerChunk, dirtyBits); - fieldDirtyCount.set(playerChunk, 64); - } catch (IllegalAccessException e) { - e.printStackTrace(); + TaskManager.IMP.sync(() -> { + try { + int dirtyBits = fieldDirtyBits.getInt(playerChunk); + if (dirtyBits == 0) { + ((CraftWorld) getWorld()).getHandle().getPlayerChunkMap().a(playerChunk); } - return null; + if (mask == 0) { + dirtyBits = 65535; + } else { + dirtyBits |= mask; + } + + fieldDirtyBits.set(playerChunk, dirtyBits); + fieldDirtyCount.set(playerChunk, 64); + } catch (IllegalAccessException e) { + e.printStackTrace(); } + return null; }); } -// if (mask == 0) { -// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65535); -// for (EntityPlayer player : playerChunk.players) { -// player.playerConnection.sendPacket(packet); -// } -// return true; -// } -// // Send chunks -// boolean empty = false; -// ChunkSection[] sections = nmsChunk.getSections(); -// for (int i = 0; i < sections.length; i++) { -// if (sections[i] == null) { -// sections[i] = emptySection; -// empty = true; -// } -// } -// if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) { -// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280); -// for (EntityPlayer player : playerChunk.players) { -// player.playerConnection.sendPacket(packet); -// } -// mask = 255; -// } -// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, mask); -// for (EntityPlayer player : playerChunk.players) { -// player.playerConnection.sendPacket(packet); -// } -// if (empty) { -// for (int i = 0; i < sections.length; i++) { -// if (sections[i] == emptySection) { -// sections[i] = null; -// } -// } -// } return true; } public boolean hasEntities(net.minecraft.server.v1_13_R2.Chunk nmsChunk) { try { final Collection[] entities = nmsChunk.entitySlices; - for (int i = 0; i < entities.length; i++) { - Collection slice = entities[i]; + for (Collection slice : entities) { if (slice != null && !slice.isEmpty()) { return true; } @@ -780,8 +539,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0 palette; -// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a); - palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d); + DataPalette palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d); // set palette for (int i = 0; i < num_palette; i++) { @@ -938,13 +694,13 @@ public class BukkitQueue_1_13 extends BukkitQueue_0 { copy.sectionPalettes[i] = copy(current); } } catch (Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } } return copy; @@ -611,7 +611,7 @@ public class BukkitChunk_1_14 extends IntFaweChunk { getParent().getChangeTask().run(copy, this); } } catch (Throwable e) { - MainUtil.handleError(e); + e.printStackTrace(); } return this; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java index 3bfd87539..b6ddf06de 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java @@ -905,7 +905,7 @@ public class BukkitQueue_1_14 extends BukkitQueue_0> 4, z >> 4); } @Override - public void setBlockData(BlockData blockData) { + public void setBlockData(@NotNull BlockData blockData) { try { queue.setBlock(x, y, z, BukkitAdapter.adapt(blockData)); } catch (WorldEditException e) { @@ -186,12 +186,12 @@ public class AsyncBlock implements Block { } @Override - public void setBlockData(BlockData blockData, boolean b) { + public void setBlockData(@NotNull BlockData blockData, boolean b) { setBlockData(blockData); } @Override - public void setType(Material type) { + public void setType(@NotNull Material type) { try { queue.setBlock(x, y, z, BukkitAdapter.adapt(type).getDefaultState()); } catch (WorldEditException e) { @@ -200,12 +200,12 @@ public class AsyncBlock implements Block { } @Override - public void setType(Material type, boolean applyPhysics) { + public void setType(@NotNull Material type, boolean applyPhysics) { setType(type); } @Override - public BlockFace getFace(Block block) { + public BlockFace getFace(@NotNull Block block) { BlockFace[] directions = BlockFace.values(); for (BlockFace face : directions) { if (this.getX() + face.getModX() == block.getX() @@ -217,7 +217,7 @@ public class AsyncBlock implements Block { return null; } - @Override + @NotNull @Override public AsyncBlockState getState() { int combined = queue.getCombinedId4Data(x, y, z, 0); BlockType type = BlockTypes.getFromStateId(combined); @@ -231,12 +231,18 @@ public class AsyncBlock implements Block { } @Override + @NotNull + public AsyncBlockState getState(boolean useSnapshot) { + return getState(); + } + + @NotNull @Override public Biome getBiome() { return world.getAdapter().adapt(queue.getBiomeType(x, z)); } @Override - public void setBiome(Biome bio) { + public void setBiome(@NotNull Biome bio) { BiomeType biome = world.getAdapter().adapt(bio); queue.setBiome(x, z, biome); } @@ -252,17 +258,17 @@ public class AsyncBlock implements Block { } @Override - public boolean isBlockFacePowered(BlockFace face) { + public boolean isBlockFacePowered(@NotNull BlockFace face) { return false; } @Override - public boolean isBlockFaceIndirectlyPowered(BlockFace face) { + public boolean isBlockFaceIndirectlyPowered(@NotNull BlockFace face) { return false; } @Override - public int getBlockPower(BlockFace face) { + public int getBlockPower(@NotNull BlockFace face) { return 0; } @@ -316,37 +322,37 @@ public class AsyncBlock implements Block { } @Override - public boolean breakNaturally(ItemStack tool) { + public boolean breakNaturally(@NotNull ItemStack tool) { return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool)); } - @Override + @NotNull @Override public Collection getDrops() { return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops()); } - @Override - public Collection getDrops(ItemStack tool) { + @NotNull @Override + public Collection getDrops(@NotNull ItemStack tool) { return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops(tool)); } @Override - public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { + public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) { this.getUnsafeBlock().setMetadata(metadataKey, newMetadataValue); } - @Override - public List getMetadata(String metadataKey) { + @NotNull @Override + public List getMetadata(@NotNull String metadataKey) { return this.getUnsafeBlock().getMetadata(metadataKey); } @Override - public boolean hasMetadata(String metadataKey) { + public boolean hasMetadata(@NotNull String metadataKey) { return this.getUnsafeBlock().hasMetadata(metadataKey); } @Override - public void removeMetadata(String metadataKey, Plugin owningPlugin) { + public void removeMetadata(@NotNull String metadataKey, @NotNull Plugin owningPlugin) { this.getUnsafeBlock().removeMetadata(metadataKey, owningPlugin); } @@ -356,12 +362,17 @@ public class AsyncBlock implements Block { } @Override - public RayTraceResult rayTrace(Location arg0, Vector arg1, double arg2, FluidCollisionMode arg3) { + public RayTraceResult rayTrace(@NotNull Location arg0, @NotNull Vector arg1, double arg2, @NotNull FluidCollisionMode arg3) { return this.getUnsafeBlock().rayTrace(arg0, arg1, arg2, arg3); } - @Override + @NotNull @Override public BoundingBox getBoundingBox() { return this.getUnsafeBlock().getBoundingBox(); } + + @Override + public @NotNull BlockSoundGroup getSoundGroup() { + return TaskManager.IMP.sync(() -> getUnsafeBlock().getSoundGroup()); + } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java index 834bbf1df..2673e0399 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java @@ -9,9 +9,9 @@ import com.boydti.fawe.util.TaskManager; import org.bukkit.Chunk; import org.bukkit.ChunkSnapshot; import org.bukkit.World; -import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; public class AsyncChunk implements Chunk { @@ -130,18 +130,18 @@ public class AsyncChunk implements Chunk { }); } -// @Override -// public BlockState[] getTileEntities(boolean b) { -// if (!isLoaded()) { -// return new BlockState[0]; -// } -// return TaskManager.IMP.sync(new RunnableVal() { -// @Override -// public void run(BlockState[] value) { -// this.value = world.getChunkAt(x, z).getTileEntities(b); -// } -// }); -// } + @Override + public @NotNull BlockState[] getTileEntities(boolean useSnapshot) { + if (!isLoaded()) { + return new BlockState[0]; + } + return TaskManager.IMP.sync(new RunnableVal() { + @Override + public void run(BlockState[] value) { + this.value = world.getChunkAt(x, z).getTileEntities(useSnapshot); + } + }); + } @Override public boolean isLoaded() { @@ -163,7 +163,6 @@ public class AsyncChunk implements Chunk { return load(false); } - @Override public boolean unload(boolean save) { return world.unloadChunk(x, z, save); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java index d61674c1e..763e4f88d 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java @@ -26,6 +26,7 @@ import org.bukkit.OfflinePlayer; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -58,7 +59,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { Map> userGroupPermissions = new HashMap<>(); - List groupKeys = config.getStringList("permissions.groups", null); + List groupKeys = config.getKeys("permissions.groups"); if (groupKeys != null) { for (String key : groupKeys) { @@ -76,7 +77,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { } } - List userKeys = config.getStringList("permissions.users", null); + List userKeys = config.getKeys("permissions.users"); if (userKeys != null) { for (String key : userKeys) { @@ -102,8 +103,8 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { } } - userPermissionsCache.put(key.toLowerCase(), permsCache); - userGroups.put(key.toLowerCase(), new HashSet<>(groups)); + userPermissionsCache.put(key.toLowerCase(Locale.ROOT), permsCache); + userGroups.put(key.toLowerCase(Locale.ROOT), new HashSet<>(groups)); } } } @@ -117,7 +118,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { } } - Set perms = userPermissionsCache.get(player.toLowerCase()); + Set perms = userPermissionsCache.get(player.toLowerCase(Locale.ROOT)); if (perms == null) { return defaultPermissionsCache.contains(permission) || defaultPermissionsCache.contains("*"); @@ -134,7 +135,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { @Override public boolean inGroup(String player, String group) { - Set groups = userGroups.get(player.toLowerCase()); + Set groups = userGroups.get(player.toLowerCase(Locale.ROOT)); if (groups == null) { return false; } @@ -144,12 +145,12 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { @Override public String[] getGroups(String player) { - Set groups = userGroups.get(player.toLowerCase()); + Set groups = userGroups.get(player.toLowerCase(Locale.ROOT)); if (groups == null) { return new String[0]; } - return groups.toArray(new String[groups.size()]); + return groups.toArray(new String[0]); } @Override diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java index 512250b33..b85ec5341 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java @@ -51,13 +51,14 @@ import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Adapts between Bukkit and WorldEdit equivalent objects. */ public enum BukkitAdapter { - INSTANCE - ; + INSTANCE; + private final IBukkitAdapter adapter; BukkitAdapter() { @@ -73,14 +74,36 @@ public enum BukkitAdapter { return INSTANCE.adapter; } + /** + * Checks equality between a WorldEdit BlockType and a Bukkit Material + * + * @param blockType The WorldEdit BlockType + * @param type The Bukkit Material + * @return If they are equal + */ public static boolean equals(BlockType blockType, Material type) { return getAdapter().equals(blockType, type); } + /** + * Convert any WorldEdit world into an equivalent wrapped Bukkit world. + * + *

If a matching world cannot be found, a {@link RuntimeException} + * will be thrown.

+ * + * @param world the world + * @return a wrapped Bukkit world + */ public static BukkitWorld asBukkitWorld(World world) { return getAdapter().asBukkitWorld(world); } + /** + * Create a WorldEdit world from a Bukkit world. + * + * @param world the Bukkit world + * @return a WorldEdit world + */ public static World adapt(org.bukkit.World world) { return getAdapter().adapt(world); } @@ -89,23 +112,48 @@ public enum BukkitAdapter { return getAdapter().adapt(world); } + /** + * Create a WorldEdit location from a Bukkit location. + * + * @param location the Bukkit location + * @return a WorldEdit location + */ public static Location adapt(org.bukkit.Location location) { + checkNotNull(location); return getAdapter().adapt(location); } + /** + * Create a Bukkit location from a WorldEdit location. + * + * @param location the WorldEdit location + * @return a Bukkit location + */ public static org.bukkit.Location adapt(Location location) { + checkNotNull(location); return getAdapter().adapt(location); } public static org.bukkit.Location adapt(org.bukkit.World world, Vector3 position) { return getAdapter().adapt(world, position); } - + public static org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position) { + checkNotNull(world); + checkNotNull(position); return getAdapter().adapt(world, position); } + /** + * Create a Bukkit location from a WorldEdit location with a Bukkit world. + * + * @param world the Bukkit world + * @param location the WorldEdit location + * @return a Bukkit location + */ public static org.bukkit.Location adapt(org.bukkit.World world, Location location) { + checkNotNull(world); + checkNotNull(location); return getAdapter().adapt(world, location); } @@ -113,23 +161,57 @@ public enum BukkitAdapter { return getAdapter().asVector(location); } + /** + * Create a WorldEdit Vector from a Bukkit location. + * + * @param location The Bukkit location + * @return a WorldEdit vector + */ public static BlockVector3 asBlockVector(org.bukkit.Location location) { + checkNotNull(location); return getAdapter().asBlockVector(location); } + /** + * Create a WorldEdit entity from a Bukkit entity. + * + * @param entity the Bukkit entity + * @return a WorldEdit entity + */ public static Entity adapt(org.bukkit.entity.Entity entity) { + checkNotNull(entity); return getAdapter().adapt(entity); } + /** + * Create a Bukkit Material form a WorldEdit ItemType + * + * @param itemType The WorldEdit ItemType + * @return The Bukkit Material + */ public static Material adapt(ItemType itemType) { + checkNotNull(itemType); return getAdapter().adapt(itemType); } - public static Material adapt(BlockType blockType) { + /** + * Create a Bukkit Material form a WorldEdit BlockType + * + * @param blockType The WorldEdit BlockType + * @return The Bukkit Material + */ + public static Material adapt(@NotNull BlockType blockType) { return getAdapter().adapt(blockType); } + /** + * Create a WorldEdit GameMode from a Bukkit one. + * + * @param gameMode Bukkit GameMode + * @return WorldEdit GameMode + */ public static GameMode adapt(org.bukkit.GameMode gameMode) { + checkNotNull(gameMode); return getAdapter().adapt(gameMode); } @@ -161,15 +243,35 @@ public enum BukkitAdapter { return getAdapter().adapt(entityType); } - public static BlockType asBlockType(Material material) { + /** + * Converts a Material to a BlockType + * + * @param material The material + * @return The blocktype + */ + public static BlockType asBlockType(@NotNull Material material) { return getAdapter().asBlockType(material); } + /** + * Converts a Material to a ItemType + * + * @param material The material + * @return The itemtype + */ public static ItemType asItemType(Material material) { + checkNotNull(material); return getAdapter().asItemType(material); } - public static BlockState adapt(BlockData blockData) { + + /** + * Create a WorldEdit BlockState from a Bukkit BlockData + * + * @param blockData The Bukkit BlockData + * @return The WorldEdit BlockState + */ + public static BlockState adapt(@NotNull BlockData blockData) { return getAdapter().adapt(blockData); } @@ -183,7 +285,7 @@ public enum BukkitAdapter { * @param block The WorldEdit BlockStateHolder * @return The Bukkit BlockData */ - public static > BlockData adapt(B block) { + public static BlockData adapt(@NotNull BlockStateHolder block) { return getAdapter().adapt(block); } @@ -191,15 +293,40 @@ public enum BukkitAdapter { return getAdapter().getBlockData(combinedId); } - public static BlockState asBlockState(ItemStack itemStack) { - return getAdapter().asBlockState(itemStack); + /** + * Create a WorldEdit BlockState from a Bukkit ItemStack + * + * @param itemStack The Bukkit ItemStack + * @return The WorldEdit BlockState + */ + public static BlockState asBlockState(ItemStack itemStack) throws WorldEditException { + checkNotNull(itemStack); + if (itemStack.getType().isBlock()) { + return getAdapter().asBlockState(itemStack); + } else { + throw new NotABlockException(); + } } + /** + * Create a WorldEdit BaseItemStack from a Bukkit ItemStack + * + * @param itemStack The Bukkit ItemStack + * @return The WorldEdit BaseItemStack + */ public static BaseItemStack adapt(ItemStack itemStack) { + checkNotNull(itemStack); return getAdapter().adapt(itemStack); } + /** + * Create a Bukkit ItemStack from a WorldEdit BaseItemStack + * + * @param item The WorldEdit BaseItemStack + * @return The Bukkit ItemStack + */ public static ItemStack adapt(BaseItemStack item) { + checkNotNull(item); return getAdapter().adapt(item); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java index 62f95d000..c1427985b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java @@ -19,28 +19,21 @@ package com.sk89q.worldedit.bukkit; -import com.bekvon.bukkit.residence.commands.material; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; -import com.sk89q.worldedit.command.tool.BlockDataCyler; -import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BundledBlockRegistry; -import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial; import org.bukkit.Material; import org.bukkit.block.data.BlockData; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collection; -import java.util.EnumMap; import java.util.Map; -import java.util.function.Function; - -import javax.annotation.Nullable; public class BukkitBlockRegistry extends BundledBlockRegistry { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitItemRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitItemRegistry.java index 9d7d68d08..d2d2cb1d7 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitItemRegistry.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitItemRegistry.java @@ -1,18 +1,6 @@ package com.sk89q.worldedit.bukkit; import com.sk89q.worldedit.world.registry.BundledItemRegistry; -import org.bukkit.Material; - -import java.util.ArrayList; -import java.util.Collection; public class BukkitItemRegistry extends BundledItemRegistry { - @Override - public Collection registerItems() { - ArrayList items = new ArrayList<>(); - for (Material m : Material.values()) { - if (!m.isLegacy() && m.isItem()) items.add(m.getKey().getNamespace() + ":" + m.getKey().getKey()); - } - return items; - } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 637c61470..9b25740c6 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.util.TaskManager; + import com.sk89q.util.StringUtil; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; @@ -41,7 +42,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameModes; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -51,12 +51,11 @@ import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import javax.annotation.Nullable; import java.util.HashMap; import java.util.Map; import java.util.UUID; -import javax.annotation.Nullable; - public class BukkitPlayer extends AbstractPlayerActor { private Player player; @@ -109,8 +108,8 @@ public class BukkitPlayer extends AbstractPlayerActor { if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) { inv.remove(newItem); } - final ItemStack item = player.getItemInHand(); - player.setItemInHand(newItem); + final ItemStack item = player.getInventory().getItemInMainHand(); + player.getInventory().setItemInMainHand(newItem); HashMap overflow = inv.addItem(item); if (!overflow.isEmpty()) { TaskManager.IMP.sync(new RunnableVal() { @@ -168,13 +167,10 @@ public class BukkitPlayer extends AbstractPlayerActor { Extent extent = loc.getExtent(); if (extent instanceof World) { org.bukkit.World world = Bukkit.getWorld(((World) extent).getName()); - // System.out.println("Teleport to world " + world); - player.teleport(new Location(world, pos.getX(), pos.getY(), - pos.getZ(), yaw, pitch)); + player.teleport(new Location(world, pos.getX(), pos.getY(), pos.getZ(), yaw, pitch)); } } - player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(), - pos.getZ(), yaw, pitch)); + player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ(), yaw, pitch)); } @Override @@ -216,7 +212,7 @@ public class BukkitPlayer extends AbstractPlayerActor { if (params.length > 0) { send = send + "|" + StringUtil.joinString(params, "|"); } - player.sendPluginMessage(plugin, WorldEditPlugin.getCuiPluginChannel(), send.getBytes(CUIChannelListener.UTF_8_CHARSET)); + player.sendPluginMessage(plugin, WorldEditPlugin.CUI_PLUGIN_CHANNEL, send.getBytes(CUIChannelListener.UTF_8_CHARSET)); } public Player getPlayer() { @@ -305,7 +301,7 @@ public class BukkitPlayer extends AbstractPlayerActor { } @Override - public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) { + public > void sendFakeBlock(BlockVector3 pos, B block) { Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ()); if (block == null) { player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData()); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java index 925fa3893..06bc2db4c 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java @@ -38,7 +38,7 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag /** * Construct the object. - * + * * @param player the player */ public BukkitPlayerBlockBag(Player player) { @@ -56,13 +56,26 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag /** * Get the player. - * + * * @return the player */ public Player getPlayer() { return player; } + @Override + public BaseItem getItem(int slot) { + loadInventory(); + return BukkitAdapter.adapt(items[slot]); + } + + @Override + public void setItem(int slot, BaseItem block) { + loadInventory(); + BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(block.getType(), block.getNbtData(), 1); + items[slot] = BukkitAdapter.adapt(stack); + } + @Override public void fetchBlock(BlockState blockState) throws BlockBagException { if (blockState.getBlockType().getMaterial().isAir()) { @@ -182,16 +195,4 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag public void addSingleSourcePosition(Location pos) { } - @Override - public BaseItem getItem(int slot) { - loadInventory(); - return BukkitAdapter.adapt(items[slot]); - } - - @Override - public void setItem(int slot, BaseItem block) { - loadInventory(); - BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(block.getType(), block.getNbtData(), 1); - items[slot] = BukkitAdapter.adapt(stack); - } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java index 2d312c19f..2415699ff 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java @@ -36,14 +36,13 @@ import org.bukkit.Server; import org.bukkit.World; import org.bukkit.entity.EntityType; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.EnumMap; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; - public class BukkitServerInterface implements MultiUserPlatform { public Server server; public WorldEditPlugin plugin; @@ -100,7 +99,7 @@ public class BukkitServerInterface implements MultiUserPlatform { return player; } else { org.bukkit.entity.Player bukkitPlayer = server.getPlayerExact(player.getName()); - return bukkitPlayer != null ? plugin.wrapPlayer(bukkitPlayer) : null; + return bukkitPlayer != null ? WorldEditPlugin.getInstance().wrapPlayer(bukkitPlayer) : null; } } @@ -119,7 +118,7 @@ public class BukkitServerInterface implements MultiUserPlatform { public void registerCommands(Dispatcher dispatcher) { List toRegister = new ArrayList<>(); BukkitCommandInspector inspector = new BukkitCommandInspector(plugin, dispatcher); - + for (CommandMapping command : dispatcher.getCommands()) { Description description = command.getDescription(); List permissions = description.getPermissions(); @@ -177,7 +176,7 @@ public class BukkitServerInterface implements MultiUserPlatform { public Collection getConnectedUsers() { List users = new ArrayList<>(); for (org.bukkit.entity.Player player : Bukkit.getServer().getOnlinePlayers()) { - users.add(plugin.wrapPlayer(player)); + users.add(WorldEditPlugin.getInstance().wrapPlayer(player)); } return users; } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 7d5599ac3..887b48e7b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -1,4 +1,5 @@ /* + * WorldEdit, a Minecraft world manipulation toolkit * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * @@ -18,11 +19,10 @@ package com.sk89q.worldedit.bukkit; -import com.boydti.fawe.Fawe; +import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.entity.BaseEntity; @@ -38,7 +38,6 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherTypes; - import org.bukkit.Effect; import org.bukkit.TreeType; import org.bukkit.World; @@ -57,7 +56,6 @@ import java.util.EnumMap; import java.util.HashMap; import java.util.List; import java.util.Map; -import static com.google.common.base.Preconditions.checkNotNull; public class BukkitWorld extends AbstractWorld { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java index 23b190616..fad38e27c 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java @@ -24,13 +24,14 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * Handles incoming WorldEditCui init message. */ public class CUIChannelListener implements PluginMessageListener { - public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); + public static final Charset UTF_8_CHARSET = StandardCharsets.UTF_8; private final WorldEditPlugin plugin; public CUIChannelListener(WorldEditPlugin plugin) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/DelegateEntity.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/DelegateEntity.java deleted file mode 100644 index 86a978f92..000000000 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/DelegateEntity.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.sk89q.worldedit.bukkit; - -import com.sk89q.worldedit.entity.BaseEntity; -import com.sk89q.worldedit.entity.Entity; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.util.Location; - -import javax.annotation.Nullable; - -public class DelegateEntity implements Entity { - private final Entity parent; - - public DelegateEntity(Entity parent) { - this.parent = parent; - } - - public Entity getParent() { - return parent; - } - - @Override - @Nullable - public BaseEntity getState() { - return parent.getState(); - } - - @Override - public Location getLocation() { - return parent.getLocation(); - } - - @Override - public Extent getExtent() { - return parent.getExtent(); - } - - @Override - public boolean remove() { - return parent.remove(); - } - - @Override - @Nullable - public T getFacet(Class cls) { - return parent.getFacet(cls); - } - - @Override - public boolean setLocation(Location location) { - return parent.setLocation(location); - } -} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java index e0613cd97..bae579d2b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java @@ -40,7 +40,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { @Override public boolean setBlockData(int x, int y, int z, BlockData blockData) { try { - editSession.setBlock(BlockVector3.at(x, y, z), BukkitAdapter.adapt(blockData)); + editSession.setBlock(x, y, z, BukkitAdapter.adapt(blockData)); } catch (MaxChangedBlocksException e) { return false; } @@ -49,7 +49,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { @Override public BlockData getBlockData(int x, int y, int z) { - return BukkitAdapter.adapt(editSession.getBlock(BlockVector3.at(x, y, z))); + return BukkitAdapter.adapt(editSession.getBlock(x, y, z)); } @Override @@ -59,7 +59,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { @Override public boolean isEmpty(int x, int y, int z) { - return editSession.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir(); + return editSession.getBlock(x, y, z).getBlockType().getMaterial().isAir(); } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java index 5a3edadaf..3f1e3cfc1 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java @@ -109,15 +109,15 @@ public class WorldEditListener implements Listener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerCommand(PlayerCommandSendEvent event) { - CommandLocals locals = new CommandLocals(); - locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer())); Dispatcher dispatcher = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher(); if (dispatcher != null) { - Set toRemove = dispatcher.getCommands().stream() - .filter(commandMapping -> !commandMapping.getCallable().testPermission(locals)) - .map(CommandMapping::getPrimaryAlias) - .collect(Collectors.toSet()); - event.getCommands().removeIf(toRemove::contains); + CommandLocals locals = new CommandLocals(); + locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer())); + Set toRemove = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher().getCommands().stream() + .filter(commandMapping -> !commandMapping.getCallable().testPermission(locals)) + .map(CommandMapping::getPrimaryAlias) + .collect(Collectors.toSet()); + event.getCommands().removeIf(toRemove::contains); } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index cdcdb6fb5..15b79a4d9 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -20,11 +20,14 @@ package com.sk89q.worldedit.bukkit; import com.bekvon.bukkit.residence.commands.message; +import com.bekvon.bukkit.residence.containers.cmd; import com.boydti.fawe.Fawe; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2; import com.boydti.fawe.util.MainUtil; + import com.google.common.base.Joiner; +import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.wepif.PermissionsResolverManager; import com.sk89q.worldedit.EditSession; @@ -34,38 +37,30 @@ import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader; import com.sk89q.worldedit.event.platform.CommandEvent; -import com.sk89q.worldedit.event.platform.CommandSuggestionEvent; import com.sk89q.worldedit.event.platform.PlatformReadyEvent; -import com.sk89q.worldedit.extension.input.InputParseException; -import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.inventory.BlockBag; -import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockCategory; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.FuzzyBlockState; import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.item.ItemCategory; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.registry.LegacyMapper; -import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.block.Biome; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPluginLoader; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,8 +80,6 @@ import java.util.jar.JarFile; import java.util.logging.Level; import java.util.zip.ZipEntry; -import static com.google.common.base.Preconditions.checkNotNull; - /** * Plugin for Bukkit. */ @@ -102,39 +95,38 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter private static Map lookupNames; static { - { // Disable AWE as otherwise both fail to load - PluginManager manager = Bukkit.getPluginManager(); - try { - Field pluginsField = manager.getClass().getDeclaredField("plugins"); - Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames"); - pluginsField.setAccessible(true); - lookupNamesField.setAccessible(true); - List plugins = (List) pluginsField.get(manager); - lookupNames = (Map) lookupNamesField.get(manager); - pluginsField.set(manager, plugins = new ArrayList(plugins) { - @Override - public boolean add(Plugin plugin) { - if (plugin.getName().startsWith("AsyncWorldEdit")) { - Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible"); - } else if (plugin.getName().startsWith("BetterShutdown")) { - Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible (Improperly shaded classes from com.sk89q.minecraft.util.commands)"); - } else { - return super.add(plugin); - } - return false; + // Disable AWE as otherwise both fail to load + PluginManager manager = Bukkit.getPluginManager(); + try { + Field pluginsField = manager.getClass().getDeclaredField("plugins"); + Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames"); + pluginsField.setAccessible(true); + lookupNamesField.setAccessible(true); + List plugins = (List) pluginsField.get(manager); + lookupNames = (Map) lookupNamesField.get(manager); + pluginsField.set(manager, new ArrayList(plugins) { + @Override + public boolean add(Plugin plugin) { + if (plugin.getName().startsWith("AsyncWorldEdit")) { + Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible"); + } else if (plugin.getName().startsWith("BetterShutdown")) { + Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible (Improperly shaded classes from com.sk89q.minecraft.util.commands)"); + } else { + return super.add(plugin); } - }); - lookupNamesField.set(manager, lookupNames = new ConcurrentHashMap(lookupNames) { - @Override - public Plugin put(String key, Plugin plugin) { - if (plugin.getName().startsWith("AsyncWorldEdit") || plugin.getName().startsWith("BetterShutdown")) { - return null; - } - return super.put(key, plugin); + return false; + } + }); + lookupNamesField.set(manager, lookupNames = new ConcurrentHashMap(lookupNames) { + @Override + public Plugin put(@NotNull String key, @NotNull Plugin plugin) { + if (plugin.getName().startsWith("AsyncWorldEdit") || plugin.getName().startsWith("BetterShutdown")) { + return null; } - }); - } catch (Throwable ignore) {} - } + return super.put(key, plugin); + } + }); + } catch (Throwable ignore) {} } public WorldEditPlugin() { @@ -157,15 +149,11 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter setEnabled(true); } - public static String getCuiPluginChannel() { - return CUI_PLUGIN_CHANNEL; - } - @Override public void onLoad() { if (INSTANCE != null) return; rename(); - this.INSTANCE = this; + INSTANCE = this; FaweBukkit imp = new FaweBukkit(this); //noinspection ResultOfMethodCallIgnored @@ -190,6 +178,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter if (INSTANCE != null) return; onLoad(); setupTags(); // these have to be done post-world since they rely on MC registries. the other ones just use Bukkit enums + //TODO: FAWE -- This needs to be moved to onLoad() setupRegistries(); WorldEdit.getInstance().loadMappings(); @@ -197,8 +186,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter // Register CUI fail(() -> { - getServer().getMessenger().registerIncomingPluginChannel(INSTANCE, CUI_PLUGIN_CHANNEL, new CUIChannelListener(INSTANCE)); - getServer().getMessenger().registerOutgoingPluginChannel(INSTANCE, CUI_PLUGIN_CHANNEL); + getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this)); + getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL); }, "Failed to register CUI"); // Now we can register events @@ -209,12 +198,11 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter // platforms to be worried about... at the current time of writing WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); - { // Register 1.13 Material ids with LegacyMapper - LegacyMapper legacyMapper = LegacyMapper.getInstance(); - for (Material m : Material.values()) { - if (!m.isLegacy() && m.isBlock()) { - legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState()); - } + // Register 1.13 Material ids with LegacyMapper + LegacyMapper legacyMapper = LegacyMapper.getInstance(); + for (Material m : Material.values()) { + if (!m.isLegacy() && m.isBlock()) { + legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState()); } } } @@ -226,28 +214,30 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter } // Block & Item for (Material material : Material.values()) { -// if (material.isBlock() && !material.isLegacy()) { -// BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> { -// // TODO Use something way less hacky than this. -// ParserContext context = new ParserContext(); -// context.setPreferringWildcard(true); -// context.setTryLegacy(false); -// context.setRestricted(false); -// try { -// FuzzyBlockState state = (FuzzyBlockState) WorldEdit.getInstance().getBlockFactory().parseFromInput( -// BukkitAdapter.adapt(blockState.getBlockType()).createBlockData().getAsString(), context -// ).toImmutableState(); -// BlockState defaultState = blockState.getBlockType().getAllStates().get(0); -// for (Map.Entry, Object> propertyObjectEntry : state.getStates().entrySet()) { -// defaultState = defaultState.with((Property) propertyObjectEntry.getKey(), propertyObjectEntry.getValue()); -// } -// return defaultState; -// } catch (InputParseException e) { -// e.printStackTrace(); -// return blockState; -// } -// })); -// } +/* + if (material.isBlock() && !material.isLegacy()) { + BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> { + // TODO Use something way less hacky than this. + ParserContext context = new ParserContext(); + context.setPreferringWildcard(true); + context.setTryLegacy(false); + context.setRestricted(false); + try { + FuzzyBlockState state = (FuzzyBlockState) WorldEdit.getInstance().getBlockFactory().parseFromInput( + BukkitAdapter.adapt(blockState.getBlockType()).createBlockData().getAsString(), context + ).toImmutableState(); + BlockState defaultState = blockState.getBlockType().getAllStates().get(0); + for (Map.Entry, Object> propertyObjectEntry : state.getStates().entrySet()) { + defaultState = defaultState.with((Property) propertyObjectEntry.getKey(), propertyObjectEntry.getValue()); + } + return defaultState; + } catch (InputParseException e) { + e.printStackTrace(); + return blockState; + } + })); + } +*/ if (material.isItem() && !material.isLegacy()) { ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString())); } @@ -276,63 +266,29 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter } private void rename() { -// { -// PluginDescriptionFile desc = getDescription(); -// if (desc != null) { -// try { -// Field nameField = PluginDescriptionFile.class.getDeclaredField("name"); -// nameField.setAccessible(true); -// nameField.set(desc, "FastAsyncWorldEdit"); -// Field descriptionField = JavaPlugin.class.getDeclaredField("description"); -// descriptionField.setAccessible(true); -// descriptionField.set(this, desc); -// } catch (Throwable ignore) { -// ignore.printStackTrace(); -// } -// } -// } - { - File dir = getDataFolder(); - if (dir != null) { - dir = new File(dir.getParentFile(), "FastAsyncWorldEdit"); - try { - Field descriptionField = JavaPlugin.class.getDeclaredField("dataFolder"); - descriptionField.setAccessible(true); - descriptionField.set(this, dir); - } catch (Throwable ignore) { - ignore.printStackTrace(); - } - } + File dir = new File(getDataFolder().getParentFile(), "FastAsyncWorldEdit"); + try { + Field descriptionField = JavaPlugin.class.getDeclaredField("dataFolder"); + descriptionField.setAccessible(true); + descriptionField.set(this, dir); + } catch (Throwable throwable) { + throwable.printStackTrace(); } -// { -// Logger logger = getLogger(); -// if (logger != null) { -// try { -// Field nameField = Logger.class.getDeclaredField("name"); -// nameField.setAccessible(true); -// nameField.set(logger, "FastAsyncWorldEdit"); -// } catch (Throwable ignore) { -// ignore.printStackTrace(); -// } -// } -// } - { - File pluginsFolder = MainUtil.getJarFile().getParentFile(); - for (File file : pluginsFolder.listFiles()) { - if (file.length() == 1988) return; - } - Plugin plugin = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"); - File dummy = MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "DummyFawe.jar"); - if (dummy != null && dummy.exists() && plugin == this) { - try { - Bukkit.getPluginManager().loadPlugin(dummy); - } catch (Throwable e) { - e.printStackTrace(); - } - getLogger().info("Please restart the server if you have any plugins which depend on FAWE."); - } else if (dummy == null) { - MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "update" + File.separator + "DummyFawe.jar"); + File pluginsFolder = MainUtil.getJarFile().getParentFile(); + for (File file : pluginsFolder.listFiles()) { + if (file.length() == 2016) return; + } + Plugin plugin = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"); + File dummy = MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "DummyFawe.jar"); + if (dummy != null && dummy.exists() && plugin == this) { + try { + Bukkit.getPluginManager().loadPlugin(dummy); + } catch (Throwable e) { + e.printStackTrace(); } + getLogger().info("Please restart the server if you have any plugins which depend on FAWE."); + } else if (dummy == null) { + MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "update" + File.separator + "DummyFawe.jar"); } } @@ -470,20 +426,20 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter return true; } -// @Deprecated Using Async tab complete (rather than main thread) -// @Override -// public List onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) { -// // Add the command to the array because the underlying command handling -// // code of WorldEdit expects it -// String[] split = new String[args.length + 1]; -// System.arraycopy(args, 0, split, 1, args.length); -// split[0] = cmd.getName(); -// -// CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), Joiner.on(" ").join(split)); -// getWorldEdit().getEventBus().post(event); -// -// return event.getSuggestions(); -// } +/* + @Override + public List onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) { + // Add the command to the array because the underlying command handling + // code of WorldEdit expects it + String[] split = new String[args.length + 1]; + System.arraycopy(args, 0, split, 1, args.length); + split[0] = cmd.getName(); + + CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), Joiner.on(" ").join(split)); + getWorldEdit().getEventBus().post(event); + return event.getSuggestions(); + } +*/ /** * Gets the session for the player. diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java index 885c3fe38..b3e7adc07 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java @@ -29,6 +29,7 @@ import org.bukkit.inventory.ItemStack; import static com.google.common.base.Preconditions.checkNotNull; public interface IBukkitAdapter { + /** * Checks equality between a WorldEdit BlockType and a Bukkit Material * @@ -101,7 +102,7 @@ public interface IBukkitAdapter { default Location adapt(org.bukkit.Location location) { checkNotNull(location); Vector3 position = asVector(location); - return new com.sk89q.worldedit.util.Location( + return new Location( adapt(location.getWorld()), position, location.getYaw(), @@ -138,7 +139,7 @@ public interface IBukkitAdapter { world, position.getX(), position.getY(), position.getZ()); } - + default org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position){ return adapt(world, position.toVector3()); } @@ -170,7 +171,7 @@ public interface IBukkitAdapter { checkNotNull(location); return Vector3.at(location.getX(), location.getY(), location.getZ()); } - + /** * Create a WorldEdit BlockVector from a Bukkit location. * diff --git a/worldedit-bukkit/src/main/resources/DummyFawe.src b/worldedit-bukkit/src/main/resources/DummyFawe.src index d41a1a0ef..5fd4b7be3 100644 Binary files a/worldedit-bukkit/src/main/resources/DummyFawe.src and b/worldedit-bukkit/src/main/resources/DummyFawe.src differ diff --git a/worldedit-bukkit/src/main/resources/defaults/config-legacy.yml b/worldedit-bukkit/src/main/resources/defaults/config-legacy.yml index 681dd21c9..ef7a2e6ad 100644 --- a/worldedit-bukkit/src/main/resources/defaults/config-legacy.yml +++ b/worldedit-bukkit/src/main/resources/defaults/config-legacy.yml @@ -3,7 +3,7 @@ # # About editing this file: # - DO NOT USE TABS. You MUST use spaces or Bukkit will complain and post -# errors. If you use an editor, like Notepad++ (recommended for Windows +# errors. If you use an editor, like Notepad++ (recommended for Windows # users), you must configure it to "replace tabs with spaces." # This can be changed in Settings > Preferences > Language Menu. # - Don't get rid of indentations. They are indented so some entries that are @@ -30,8 +30,6 @@ limits: butcher-radius: default: -1 maximum: -1 - # Use either block ids, names, or regex - # Regex supports properties as well (see FAWE mask documentation) disallowed-blocks: [] use-inventory: diff --git a/worldedit-core/build.gradle b/worldedit-core/build.gradle index ae5138932..a06223774 100644 --- a/worldedit-core/build.gradle +++ b/worldedit-core/build.gradle @@ -1,32 +1,51 @@ +apply plugin: 'java-library' apply plugin: 'eclipse' apply plugin: 'idea' repositories { maven {url "http://ci.athion.net/job/PlotSquared-Breaking/ws/mvn/"} } + +configurations.all { Configuration it -> + it.resolutionStrategy { ResolutionStrategy rs -> + rs.force("com.google.guava:guava:21.0") + } +} + dependencies { + compile project(':worldedit-libs:core') compile 'de.schlichtherle:truezip:6.8.3' compile 'rhino:js:1.7R2' + compile 'org.yaml:snakeyaml:1.23' compile 'com.google.guava:guava:21.0' - compile 'com.sk89q:jchronic:0.2.4a' compile 'com.google.code.findbugs:jsr305:1.3.9' compile 'com.thoughtworks.paranamer:paranamer:2.6' compile 'com.google.code.gson:gson:2.8.0' - compile 'com.sk89q.lib:jlibnoise:1.0.0' compile 'com.googlecode.json-simple:json-simple:1.1.1' compile 'org.slf4j:slf4j-api:1.7.26' + + compileOnly project(':worldedit-libs:core:ap') + annotationProcessor project(':worldedit-libs:core:ap') + annotationProcessor "com.google.guava:guava:21.0" + def avVersion = "1.6.5" + compileOnly "com.google.auto.value:auto-value-annotations:$avVersion" + annotationProcessor "com.google.auto.value:auto-value:$avVersion" //compile 'net.sf.trove4j:trove4j:3.0.3' testCompile 'org.mockito:mockito-core:1.9.0-rc1' // Fawe depends - compile 'org.yaml:snakeyaml:1.19' compile 'net.fabiozumbi12:redprotect:1.9.6' compile ("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") { transitive = false } + compile 'com.mojang:datafixerupper:1.0.20' compile 'com.github.luben:zstd-jni:1.1.1' compile 'co.aikar:fastutil-lite:1.0' } +tasks.withType(JavaCompile).configureEach { + it.options.compilerArgs.add("-Aarg.name.key.prefix=") +} + sourceSets { main { java { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index 02ccee892..fb751c22b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -166,21 +166,6 @@ public class Fawe { this.timer = new FaweTimer(); Fawe.this.IMP.setupVault(); - File jar = MainUtil.getJarFile(); - // TODO FIXME remove extrablocks.json -// File extraBlocks = MainUtil.copyFile(jar, "extrablocks.json", null); -// if (extraBlocks != null && extraBlocks.exists()) { -// TaskManager.IMP.task(() -> { -// try { -// BundledBlockData.getInstance().loadFromResource(); -// BundledBlockData.getInstance().add(extraBlocks.toURI().toURL(), true); -// } catch (Throwable ignore) { -// ignore.printStackTrace(); -// Fawe.debug("Invalid format: extrablocks.json"); -// } -// }); -// } - // Delayed worldedit setup TaskManager.IMP.later(() -> { try { @@ -207,11 +192,6 @@ public class Fawe { this.chatManager = chatManager; } - // @Deprecated -// public boolean isJava8() { -// return isJava8; -// } - public DefaultTransformParser getTransformParser() { return transformParser; } @@ -295,11 +275,10 @@ public class Fawe { Settings.IMP.PLATFORM = IMP.getPlatform().replace("\"", ""); try (InputStream stream = getClass().getResourceAsStream("/fawe.properties"); BufferedReader br = new BufferedReader(new InputStreamReader(stream))) { - // java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A"); String versionString = br.readLine(); String commitString = br.readLine(); String dateString = br.readLine(); - // scanner.close(); + br.close(); this.version = FaweVersion.tryParse(versionString, commitString, dateString); Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString(); Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/" + version.build; @@ -361,7 +340,7 @@ public class Fawe { try { String arch = System.getenv("PROCESSOR_ARCHITECTURE"); String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432"); - boolean x86OS = arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64") ? false : true; + boolean x86OS = !(arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64")); boolean x86JVM = System.getProperty("sun.arch.data.model").equals("32"); if (x86OS != x86JVM) { debug("====== UPGRADE TO 64-BIT JAVA ======"); @@ -403,7 +382,7 @@ public class Fawe { } } catch (Throwable e) { debug("====== MEMORY LISTENER ERROR ======"); - MainUtil.handleError(e, false); + e.printStackTrace(); debug("==================================="); debug("FAWE needs access to the JVM memory system:"); debug(" - Change your Java security settings"); @@ -422,7 +401,7 @@ public class Fawe { } public static boolean isMainThread() { - return INSTANCE != null ? INSTANCE.thread == Thread.currentThread() : true; + return INSTANCE == null || INSTANCE.thread == Thread.currentThread(); } /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java index a6b0275a1..763b22c02 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -4,10 +4,8 @@ import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.example.NMSMappedFaweQueue; import com.boydti.fawe.example.NMSRelighter; -import com.boydti.fawe.object.FaweLocation; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FaweQueue; -import com.boydti.fawe.object.PseudoRandom; import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.schematic.Schematic; @@ -37,8 +35,11 @@ import com.sk89q.worldedit.internal.registry.AbstractFactory; import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.World; +import org.jetbrains.annotations.NotNull; + import java.io.File; import java.io.IOException; import java.lang.reflect.Field; @@ -67,7 +68,7 @@ public class FaweAPI { * * @param world * @return A new EditSessionBuilder - * @see com.boydti.fawe.util.EditSessionBuilder + * @see EditSessionBuilder */ public static EditSessionBuilder getEditSessionBuilder(World world) { return new EditSessionBuilder(world); @@ -182,7 +183,7 @@ public class FaweAPI { * @param world The name of the world * @param autoqueue If it should start dispatching before you enqueue it. * @return - * @see com.boydti.fawe.object.FaweQueue#enqueue() + * @see FaweQueue#enqueue() */ public static FaweQueue createQueue(World world, boolean autoqueue) { return SetQueue.IMP.getNewQueue(world, true, autoqueue); @@ -191,11 +192,6 @@ public class FaweAPI { public static World getWorld(String worldName) { Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING); List worlds = platform.getWorlds(); - for (World current : worlds) { - if (Fawe.imp().getWorldName(current).equals(worldName)) { - return WorldWrapper.wrap(current); - } - } for (World current : worlds) { if (current.getName().equals(worldName)) { return WorldWrapper.wrap(current); @@ -220,8 +216,8 @@ public class FaweAPI { * * @param file * @return - * @see com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat - * @see com.boydti.fawe.object.schematic.Schematic + * @see ClipboardFormat + * @see Schematic */ public static Schematic load(File file) throws IOException { return ClipboardFormats.findByFile(file).load(file); @@ -245,15 +241,6 @@ public class FaweAPI { return MemUtil.isMemoryLimited(); } - /** - * Use ThreadLocalRandom instead - * - */ - @Deprecated - public static PseudoRandom getFastRandom() { - throw new UnsupportedOperationException("Please Use ThreadLocalRandom instead."); - } - /** * Get a player's allowed WorldEdit region * @@ -271,7 +258,7 @@ public class FaweAPI { * * @param extent * @param reason - * @see com.sk89q.worldedit.EditSession#getRegionExtent() To get the FaweExtent for an EditSession + * @see EditSession#getRegionExtent() To get the FaweExtent for an EditSession */ public static void cancelEdit(Extent extent, BBC reason) { try { @@ -332,8 +319,13 @@ public class FaweAPI { * Reading only part of the file will result in unreliable bounds info for large edits * @return */ - public static List getBDFiles(FaweLocation origin, UUID user, int radius, long timediff, boolean shallow) { - File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + origin.world); + public static List getBDFiles(Location origin, UUID user, int radius, long timediff, boolean shallow) { + Extent extent = origin.getExtent(); + if (!(extent instanceof World)) { + throw new IllegalArgumentException("Origin is not a valid world"); + } + World world = (World) extent; + File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world)); if (!history.exists()) { return new ArrayList<>(); } @@ -364,7 +356,6 @@ public class FaweAPI { } } } - World world = origin.getWorld(); files.sort((a, b) -> { String aName = a.getName(); String bName = b.getName(); @@ -373,7 +364,7 @@ public class FaweAPI { long value = aI - bI; return value == 0 ? 0 : value < 0 ? -1 : 1; }); - RegionWrapper bounds = new RegionWrapper(origin.x - radius, origin.x + radius, origin.z - radius, origin.z + radius); + RegionWrapper bounds = new RegionWrapper(origin.getBlockX() - radius, origin.getBlockX() + radius, origin.getBlockZ() - radius, origin.getBlockZ() + radius); RegionWrapper boundsPlus = new RegionWrapper(bounds.minX - 64, bounds.maxX + 512, bounds.minZ - 64, bounds.maxZ + 512); HashSet regionSet = Sets.newHashSet(bounds); ArrayList result = new ArrayList<>(); @@ -410,7 +401,7 @@ public class FaweAPI { * @param uuid * @param index * @return - * @see com.boydti.fawe.object.changeset.DiskStorageHistory#toEditSession(com.boydti.fawe.object.FawePlayer) + * @see DiskStorageHistory#toEditSession(FawePlayer) */ public static DiskStorageHistory getChangeSetFromDisk(World world, UUID uuid, int index) { return new DiskStorageHistory(world, uuid, index); @@ -527,25 +518,4 @@ public class FaweAPI { return BBC.values(); } - /** - * @see #getEditSessionBuilder(com.sk89q.worldedit.world.World) - * @deprecated - */ - @Deprecated - public static EditSession getNewEditSession(@Nonnull FawePlayer player) { - if (player == null) { - throw new IllegalArgumentException("Player may not be null"); - } - return player.getNewEditSession(); - } - - /** - * @see #getEditSessionBuilder(com.sk89q.worldedit.world.World) - * @deprecated - */ - @Deprecated - public static EditSession getNewEditSession(World world) { - return WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1); - } - } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java index cea5c6ac5..ae9c913f3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java @@ -13,7 +13,7 @@ public class FaweVersion { public FaweVersion(String version, String commit, String date) { String[] split = version.substring(version.indexOf('=') + 1).split("\\."); - this.build = Integer.parseInt(split[1]); + this.build = Integer.parseInt(split[2]); this.hash = Integer.parseInt(commit.substring(commit.indexOf('=') + 1), 16); String[] split1 = date.substring(date.indexOf('=') + 1).split("\\."); this.year = Integer.parseInt(split1[0]); @@ -30,9 +30,12 @@ public class FaweVersion { } } - @Override - public String toString() { - return "FastAsyncWorldEdit-" + year + "." + month + "." + day + "-" + Integer.toHexString(hash) + "-" + build; + @Override public String toString() { + if (hash == 0 && build == 0) { + return "FastAsyncWorldEdit-1.13-NoVer-SNAPSHOT"; + } else { + return "FastAsyncWorldEdit-1.13" + build; + } } public boolean isNewer(FaweVersion other) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java index af59b4096..304d9d1cb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java @@ -37,8 +37,6 @@ public interface IFawe { default ImageViewer getImageViewer(FawePlayer player) { return null; } - default void registerPacketListener() {} - default int getPlayerCount() { return Fawe.get().getCachedPlayers().size(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java index 22d04895d..c1430dab8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java @@ -111,7 +111,7 @@ public class AnvilCommands { } CuboidRegion cuboid = (CuboidRegion) selection; RegionWrapper wrappedRegion = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint()); - String worldName = Fawe.imp().getWorldName(editSession.getWorld()); + String worldName = editSession.getWorld().getName(); FaweQueue tmp = SetQueue.IMP.getNewQueue(worldName, true, false); MCAQueue queue = new MCAQueue(tmp); FawePlayer fp = FawePlayer.wrap(player); @@ -127,7 +127,7 @@ public class AnvilCommands { if (session == null || session.hasFastMode()) { run.accept(new NullAnvilHistory()); } else { - AnvilHistory history = new AnvilHistory(Fawe.imp().getWorldName(world), fp.getUUID()); + AnvilHistory history = new AnvilHistory(world.getName(), fp.getUUID()); run.accept(history); session.remember(fp.getPlayer(), world, history, fp.getLimit()); } @@ -157,7 +157,7 @@ public class AnvilCommands { // final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true)); // ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); // ReplaceSimpleFilter result = runWithWorld(player, folder, filter, true); -// if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); +// if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @Command( @@ -173,16 +173,11 @@ public class AnvilCommands { ClipboardRemapper mapper; ClipboardRemapper.RemapPlatform from; ClipboardRemapper.RemapPlatform to; - if (Fawe.imp().getPlatform().equalsIgnoreCase("nukkit")) { - from = ClipboardRemapper.RemapPlatform.PC; - to = ClipboardRemapper.RemapPlatform.PE; - } else { - from = ClipboardRemapper.RemapPlatform.PE; - to = ClipboardRemapper.RemapPlatform.PC; - } + from = ClipboardRemapper.RemapPlatform.PE; + to = ClipboardRemapper.RemapPlatform.PC; RemapFilter filter = new RemapFilter(from, to); RemapFilter result = runWithWorld(player, folder, filter, true); - if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @@ -199,10 +194,9 @@ public class AnvilCommands { ) @CommandPermissions("worldedit.anvil.deleteallunvisited") public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Optional("60000") int fileDurationMillis) throws WorldEditException { - long chunkInactivityMillis = fileDurationMillis; // Use same value for now - DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, chunkInactivityMillis); + DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true); - if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @Command( @@ -218,12 +212,11 @@ public class AnvilCommands { ) @CommandPermissions("worldedit.anvil.deleteallunclaimed") public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException { - String folder = Fawe.imp().getWorldName(player.getWorld()); - long chunkInactivityMillis = fileDurationMillis; // Use same value for now - DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis); + String folder = player.getWorld().getName(); + DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); if (debug) filter.enableDebug(); DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true); - if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @Command( @@ -239,12 +232,10 @@ public class AnvilCommands { ) @CommandPermissions("worldedit.anvil.deleteunclaimed") public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException { - String folder = Fawe.imp().getWorldName(player.getWorld()); - long chunkInactivityMillis = fileDurationMillis; // Use same value for now - DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis); + DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); if (debug) filter.enableDebug(); DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter); - if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @Command( @@ -260,10 +251,10 @@ public class AnvilCommands { ) @CommandPermissions("worldedit.anvil.deletealloldregions") public void deleteAllOldRegions(Player player, String folder, String time) throws WorldEditException { - long duration = MainUtil.timeToSec(time) * 1000l; + long duration = MainUtil.timeToSec(time) * 1000L; DeleteOldFilter filter = new DeleteOldFilter(duration); DeleteOldFilter result = runWithWorld(player, folder, filter, true); - if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @Command( @@ -276,14 +267,14 @@ public class AnvilCommands { ) @CommandPermissions("worldedit.anvil.trimallplots") public void trimAllPlots(Player player, @Switch('v') boolean deleteUnvisited) throws WorldEditException { - String folder = Fawe.imp().getWorldName(player.getWorld()); + String folder = player.getWorld().getName(); int visitTime = deleteUnvisited ? 1 : -1; PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000); // PlotTrimFilter result = runWithWorld(player, folder, filter, true); FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false); MCAQueue queue = new MCAQueue(defaultQueue); PlotTrimFilter result = queue.filterWorld(filter); - if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @Command( @@ -294,7 +285,7 @@ public class AnvilCommands { public void deleteBiome(Player player, String folder, BiomeType biome, @Switch('u') boolean unsafe) { DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome); DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe); - if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @Command( @@ -305,7 +296,7 @@ public class AnvilCommands { public void trimAllAir(Player player, String folder, @Switch('u') boolean unsafe) throws WorldEditException { TrimAirFilter filter = new TrimAirFilter(); TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe); - if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @Command( @@ -316,7 +307,7 @@ public class AnvilCommands { public void debugfixroads(Player player, String folder) throws WorldEditException { DebugFixP2Roads filter = new DebugFixP2Roads(); DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true); - if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @Command( @@ -335,7 +326,7 @@ public class AnvilCommands { // List split = StringMan.split(from, ','); // filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData); // } else { -// player.print(BBC.getPrefix() + "Must be a pattern list!"); +// player.print("Must be a pattern list!"); // return; // } // } else { @@ -348,7 +339,7 @@ public class AnvilCommands { // filter = new ReplacePatternFilter(matchFrom, to); // } // MCAFilterCounter result = runWithWorld(player, folder, filter, true); -// if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); +// if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } // @Command( @@ -373,7 +364,7 @@ public class AnvilCommands { // filter = counter; // } // MCAFilterCounter result = runWithWorld(player, folder, filter, true); -// if (result != null) player.print(BBC.getPrefix() + BBC.SELECTION_COUNT.format(result.getTotal())); +// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal())); } @Command( @@ -423,7 +414,7 @@ public class AnvilCommands { } }; MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); - if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } @Command( @@ -448,7 +439,7 @@ public class AnvilCommands { // filter = counter; // } // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); -// if (result != null) player.print(BBC.getPrefix() + BBC.SELECTION_COUNT.format(result.getTotal())); +// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal())); } // @Command( @@ -514,7 +505,7 @@ public class AnvilCommands { // ((c[1] * 10000) / total) / 100d, // name == null ? "Unknown" : name, // block.getType(), block.getData()); -// player.print(BBC.getPrefix() + str); +// player.print(str); // } // } else { // for (long[] c : map) { @@ -523,7 +514,7 @@ public class AnvilCommands { // String.valueOf(c[1]), // ((c[1] * 10000) / total) / 100d, // block == null ? "Unknown" : block.getName(), c[0]); -// player.print(BBC.getPrefix() + str); +// player.print(str); // } // } } @@ -545,7 +536,7 @@ public class AnvilCommands { // ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // if (result != null) { -// player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // } } // @@ -563,7 +554,7 @@ public class AnvilCommands { // List split = StringMan.split(from, ','); // filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData); // } else { -// player.print(BBC.getPrefix() + "Must be a pattern list!"); +// player.print("Must be a pattern list!"); // return; // } // } else { @@ -577,7 +568,7 @@ public class AnvilCommands { // } // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // if (result != null) { -// player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // } } @@ -592,7 +583,7 @@ public class AnvilCommands { MCAFilterCounter filter = new SetPatternFilter(to); MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); if (result != null) { - player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } } @@ -611,7 +602,7 @@ public class AnvilCommands { RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id); MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); if (result != null) { - player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); + player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); } } @@ -627,7 +618,7 @@ public class AnvilCommands { return; } CuboidRegion cuboid = (CuboidRegion) selection; - String worldName = Fawe.imp().getWorldName(editSession.getWorld()); + String worldName = editSession.getWorld().getName(); FaweQueue tmp = SetQueue.IMP.getNewQueue(worldName, true, false); MCAQueue queue = new MCAQueue(tmp); BlockVector3 origin = session.getPlacementPosition(player); @@ -651,7 +642,7 @@ public class AnvilCommands { // FawePlayer fp = FawePlayer.wrap(player); // MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD); // if (clipboard == null) { -// fp.sendMessage(BBC.getPrefix() + "You must first use `//anvil copy`"); +// fp.sendMessage("You must first use `//anvil copy`"); // return; // } // CuboidRegion cuboid = clipboard.getRegion(); @@ -676,4 +667,4 @@ public class AnvilCommands { // }); // BBC.COMMAND_PASTE.send(player, player.getPosition().toBlockVector()); } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java index 404fef5da..feff6cd22 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java @@ -177,7 +177,7 @@ public class CFICommands extends MethodCommands { @CommandPermissions("worldedit.anvil.cfi") public void cancel(FawePlayer fp) throws ParameterException, IOException { getSettings(fp).remove(); - fp.sendMessage(BBC.getPrefix() + "Cancelled!"); + fp.sendMessage("Cancelled!"); } @Command( @@ -196,12 +196,12 @@ public class CFICommands extends MethodCommands { if (folder != null) { try { generator.setFolder(folder); - fp.sendMessage(BBC.getPrefix() + "Generating " + folder); + fp.sendMessage("Generating " + folder); generator.generate(); generator.setPacketViewer(null); generator.setImageViewer(null); settings.remove(); - fp.sendMessage(BBC.getPrefix() + "Done!"); + fp.sendMessage("Done!"); return true; } catch (IOException e) { throw new RuntimeException(e); @@ -215,8 +215,8 @@ public class CFICommands extends MethodCommands { try { new PlotLoader().load(fp, settings, function); - } catch (Throwable ignore) { - ignore.printStackTrace(); + } catch (Throwable e) { + e.printStackTrace(); function.apply(generator.getFolder().getParentFile()); } @@ -879,7 +879,7 @@ public class CFICommands extends MethodCommands { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, "jpg", baos ); byte[] data = baos.toByteArray(); - fp.sendMessage(BBC.getPrefix() + "Please wait..."); + fp.sendMessage("Please wait..."); URL url = ImgurUtility.uploadImage(data); BBC.DOWNLOAD_LINK.send(fp, url); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/FaweParser.java b/worldedit-core/src/main/java/com/boydti/fawe/command/FaweParser.java index 2e7c334ed..337636a97 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/FaweParser.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/FaweParser.java @@ -75,7 +75,7 @@ public abstract class FaweParser extends InputParser { } } } - inputs.add(toParse.substring(last, toParse.length())); + inputs.add(toParse.substring(last)); for (int i = 0; i < inputs.size(); i++) { String full = inputs.get(i); String command = full; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java b/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java index 8c4402947..4cecdfe0c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java @@ -50,7 +50,7 @@ public class PlotLoader { SinglePlotArea area = sManager.getArea(); PlotPlayer player = PlotPlayer.wrap(fp.parent); - fp.sendMessage(BBC.getPrefix() + "Claiming world"); + fp.sendMessage("Claiming world"); Plot plot = TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Plot o) { @@ -65,12 +65,9 @@ public class PlotLoader { area.setMeta("lastPlot", new PlotId(0, 0)); } PlotId lastId = (PlotId) area.getMeta("lastPlot"); - while (true) { + do { lastId = Auto.getNextPlotId(lastId, 1); - if (area.canClaim(player, lastId, lastId)) { - break; - } - } + } while (!area.canClaim(player, lastId, lastId)); area.setMeta("lastPlot", lastId); this.value = area.getPlot(lastId); this.value.setOwner(player.getUUID()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java index 31b4d2dc4..a0a0a57ce 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java @@ -4,18 +4,14 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.object.FaweCommand; -import com.boydti.fawe.object.FaweLocation; -import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.object.RegionWrapper; -import com.boydti.fawe.object.RunnableVal; +import com.boydti.fawe.object.*; import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.Arrays; import java.util.List; @@ -65,16 +61,16 @@ public class Rollback extends FaweCommand { return false; } player.deleteMeta(FawePlayer.METADATA_KEYS.ROLLBACK); - final FaweLocation origin = player.getLocation(); + Location origin = player.getPlayer().getLocation(); rollback(player, !player.hasPermission("fawe.rollback.deep"), Arrays.copyOfRange(args, 1, args.length), new RunnableVal>() { @Override public void run(List edits) { long total = 0; player.sendMessage("&d=| Username | Bounds | Distance | Changes | Age |="); for (DiskStorageHistory edit : edits) { - DiskStorageHistory.DiskStorageSummary summary = edit.summarize(new RegionWrapper(origin.x, origin.x, origin.z, origin.z), !player.hasPermission("fawe.rollback.deep")); + DiskStorageHistory.DiskStorageSummary summary = edit.summarize(new RegionWrapper(origin.getBlockX(), origin.getBlockX(), origin.getBlockZ(), origin.getBlockZ()), !player.hasPermission("fawe.rollback.deep")); RegionWrapper region = new RegionWrapper(summary.minX, summary.maxX, summary.minZ, summary.maxZ); - int distance = region.distance(origin.x, origin.z); + int distance = region.distance(origin.getBlockX(), origin.getBlockZ()); String name = Fawe.imp().getName(edit.getUUID()); long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000; total += edit.getBDFile().length(); @@ -106,7 +102,7 @@ public class Rollback extends FaweCommand { BBC.NO_PERM.send(player, "fawe.rollback.perform"); return false; } - final List edits = (List) player.getMeta(FawePlayer.METADATA_KEYS.ROLLBACK); + final List edits = player.getMeta(FawePlayer.METADATA_KEYS.ROLLBACK); player.deleteMeta(FawePlayer.METADATA_KEYS.ROLLBACK); if (edits == null) { BBC.COMMAND_SYNTAX.send(player, "/frb info u: r: t: