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 #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 <T> 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;
}
}

View File

@ -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<CommandInfo> 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;
}

View File

@ -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);