Use a long to refer to the volume of a region to prevent overflow (#1350)

* Use a long to refer to the volume of a region, and rename the method to getVolume

* Fixed issues noted in review

* Forgot to floor

* Fixed review notes

* Can use a long here rather than BigDecimal

* Improve javadocs

* style

(cherry picked from commit 328030fd6281e58a4ea1d0cdd0a2e274da90afbe)
This commit is contained in:
Matthew Miller
2020-06-08 05:50:17 -04:00
committed by MattBDev
parent a23b182de5
commit 33adba4a6f
27 changed files with 225 additions and 124 deletions

View File

@ -20,11 +20,6 @@
package com.sk89q.bukkit.util;
import com.sk89q.util.ReflectionUtil;
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;
@ -33,6 +28,12 @@ import org.bukkit.command.PluginIdentifiableCommand;
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;
public class CommandRegistration {
static {
@ -61,6 +62,7 @@ public class CommandRegistration {
}
return null;
}
public boolean register(List<CommandInfo> registered) {
CommandMap commandMap = getCommandMap();
if (registered == null || commandMap == null) {
@ -82,12 +84,13 @@ public class CommandRegistration {
if (fallbackCommands != null) {
return fallbackCommands;
}
CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
if (commandMap == null) {
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);
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;
}