Minor tweaks

This commit is contained in:
MattBDev 2020-01-10 13:29:20 -05:00
parent b88d7b3e60
commit 98d0420c08
3 changed files with 39 additions and 15 deletions

View File

@ -75,8 +75,7 @@ import org.jetbrains.annotations.Nullable;
* @see #wrap(World) * @see #wrap(World)
* @see #create(WorldCreator) * @see #create(WorldCreator)
*/ */
public class AsyncWorld public class AsyncWorld extends PassthroughExtent implements World {
extends PassthroughExtent implements World {
private World parent; private World parent;
private BukkitImplAdapter adapter; private BukkitImplAdapter adapter;
@ -1361,6 +1360,15 @@ public class AsyncWorld
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count,
double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data,
boolean force) { 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;
} }
} }

View File

@ -20,17 +20,18 @@
package com.sk89q.bukkit.util; package com.sk89q.bukkit.util;
import com.sk89q.util.ReflectionUtil; 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.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; 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 { public class CommandRegistration {
@ -40,6 +41,7 @@ public class CommandRegistration {
protected final Plugin plugin; protected final Plugin plugin;
protected final CommandExecutor executor; protected final CommandExecutor executor;
private CommandMap serverCommandMap;
private CommandMap fallbackCommands; private CommandMap fallbackCommands;
public CommandRegistration(Plugin plugin) { public CommandRegistration(Plugin plugin) {
@ -51,6 +53,14 @@ public class CommandRegistration {
this.executor = executor; 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<CommandInfo> registered) { public boolean register(List<CommandInfo> registered) {
CommandMap commandMap = getCommandMap(); CommandMap commandMap = getCommandMap();
if (registered == null || commandMap == null) { if (registered == null || commandMap == null) {
@ -66,16 +76,20 @@ public class CommandRegistration {
} }
public CommandMap getCommandMap() { public CommandMap getCommandMap() {
if (serverCommandMap != null) {
return serverCommandMap;
}
if (fallbackCommands != null) {
return fallbackCommands;
}
CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap"); CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
if (commandMap == null) { if (commandMap == null) {
if (fallbackCommands != null) {
commandMap = fallbackCommands;
} else {
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() + Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() +
": Could not retrieve server CommandMap, using fallback instead!"); ": Could not retrieve server CommandMap, using fallback instead!");
fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer()); fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer());
Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin); Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin);
} } else {
serverCommandMap = commandMap;
} }
return commandMap; return commandMap;
} }

View File

@ -69,10 +69,12 @@ public interface IBatchProcessor {
try { try {
int layer = (minY - 15) >> 4; int layer = (minY - 15) >> 4;
while (layer < (maxY + 15) >> 4) { while (layer < (maxY + 15) >> 4) {
if (set.hasSection(layer)) { if (layer > -1) {
return true; if (set.hasSection(layer)) {
return true;
}
layer++;
} }
layer++;
} }
} catch (ArrayIndexOutOfBoundsException exception) { } catch (ArrayIndexOutOfBoundsException exception) {
Fawe.imp().debug("minY = " + minY); Fawe.imp().debug("minY = " + minY);