From 98d0420c0861f6eff1f80f025fe814c46bbeb001 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Fri, 10 Jan 2020 13:29:20 -0500 Subject: [PATCH] Minor tweaks --- .../fawe/bukkit/wrapper/AsyncWorld.java | 12 +++++-- .../bukkit/util/CommandRegistration.java | 34 +++++++++++++------ .../com/boydti/fawe/beta/IBatchProcessor.java | 8 +++-- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java index a63296229..0bab4e746 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java @@ -75,8 +75,7 @@ import org.jetbrains.annotations.Nullable; * @see #wrap(World) * @see #create(WorldCreator) */ -public class AsyncWorld - extends PassthroughExtent implements World { +public class AsyncWorld extends PassthroughExtent implements World { private World parent; private BukkitImplAdapter adapter; @@ -1361,6 +1360,15 @@ public class AsyncWorld public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data, boolean force) { + parent.spawnParticle(particle, location, count, offsetX, offsetY, offsetZ, extra, data, force); + } + public void setHardcore(boolean hardcore) { + //todo + } + + public boolean isHardcore() { + //todo + return false; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java index e7df6832c..079e14a29 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java @@ -20,17 +20,18 @@ package com.sk89q.bukkit.util; import com.sk89q.util.ReflectionUtil; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandMap; -import org.bukkit.command.SimpleCommandMap; -import org.bukkit.plugin.Plugin; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandMap; +import org.bukkit.command.PluginIdentifiableCommand; +import org.bukkit.command.SimpleCommandMap; +import org.bukkit.plugin.Plugin; public class CommandRegistration { @@ -40,6 +41,7 @@ public class CommandRegistration { protected final Plugin plugin; protected final CommandExecutor executor; + private CommandMap serverCommandMap; private CommandMap fallbackCommands; public CommandRegistration(Plugin plugin) { @@ -51,6 +53,14 @@ public class CommandRegistration { this.executor = executor; } + public Plugin getCommandOwner(String label) { + if (serverCommandMap == null) return null; + Command command = serverCommandMap.getCommand(label); + if (command instanceof PluginIdentifiableCommand) { + return ((PluginIdentifiableCommand) command).getPlugin(); + } + return null; + } public boolean register(List registered) { CommandMap commandMap = getCommandMap(); if (registered == null || commandMap == null) { @@ -66,16 +76,20 @@ public class CommandRegistration { } public CommandMap getCommandMap() { + if (serverCommandMap != null) { + return serverCommandMap; + } + if (fallbackCommands != null) { + return fallbackCommands; + } CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap"); if (commandMap == null) { - if (fallbackCommands != null) { - commandMap = fallbackCommands; - } else { Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() + ": Could not retrieve server CommandMap, using fallback instead!"); fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer()); Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin); - } + } else { + serverCommandMap = commandMap; } return commandMap; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java index 6af9d4591..84f19d8f9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java @@ -69,10 +69,12 @@ public interface IBatchProcessor { try { int layer = (minY - 15) >> 4; while (layer < (maxY + 15) >> 4) { - if (set.hasSection(layer)) { - return true; + if (layer > -1) { + if (set.hasSection(layer)) { + return true; + } + layer++; } - layer++; } } catch (ArrayIndexOutOfBoundsException exception) { Fawe.imp().debug("minY = " + minY);