mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-30 06:33:49 +01:00
Code smell improvements and null protections
This commit is contained in:
parent
1d6dba8d59
commit
b5202c3944
@ -1,5 +1,6 @@
|
||||
package world.bentobox.bentobox.api.panels.builders;
|
||||
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -16,7 +17,7 @@ import world.bentobox.bentobox.api.user.User;
|
||||
*/
|
||||
public class PanelBuilder {
|
||||
private String name;
|
||||
private final TreeMap<Integer, PanelItem> items = new TreeMap<>();
|
||||
private final SortedMap<Integer, PanelItem> items = new TreeMap<>();
|
||||
private int size;
|
||||
private User user;
|
||||
private PanelListener listener;
|
||||
@ -120,7 +121,7 @@ public class PanelBuilder {
|
||||
/**
|
||||
* @return the items
|
||||
*/
|
||||
public TreeMap<Integer, PanelItem> getItems() {
|
||||
public SortedMap<Integer, PanelItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,6 @@ public class BlueprintPaster {
|
||||
// Center, and just a bit high
|
||||
Location center = location.add(new Vector(0.5, 0.5, 0.5));
|
||||
LivingEntity e = (LivingEntity)location.getWorld().spawnEntity(center, k.getType());
|
||||
if (e == null) return;
|
||||
if (k.getCustomName() != null) {
|
||||
e.setCustomName(k.getCustomName());
|
||||
}
|
||||
|
@ -214,6 +214,7 @@ public class Island implements DataObject {
|
||||
this.world = island.world;
|
||||
this.cooldowns = island.cooldowns;
|
||||
this.commandRanks = island.commandRanks;
|
||||
this.reserved = island.reserved;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -153,6 +153,7 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
continue;
|
||||
}
|
||||
// Get the getter and setters for this field using the JavaBeans system
|
||||
//noinspection RedundantCast
|
||||
PropertyDescriptor propertyDescriptor = new PropertyDescriptor((String)field.getName(), dataObject);
|
||||
// Get the write method
|
||||
Method method = propertyDescriptor.getWriteMethod();
|
||||
@ -344,6 +345,7 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
continue;
|
||||
}
|
||||
// Get the property descriptor for this field
|
||||
//noinspection RedundantCast
|
||||
PropertyDescriptor propertyDescriptor = new PropertyDescriptor((String)field.getName(), dataObject);
|
||||
// Get the read method
|
||||
Method method = propertyDescriptor.getReadMethod();
|
||||
|
@ -50,6 +50,7 @@ public class CommandsManager {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Command> knownCommands = (Map<String, Command>) commandMap.getClass().getMethod("getKnownCommands").invoke(commandMap);
|
||||
//noinspection SuspiciousMethodCalls
|
||||
knownCommands.values().removeIf(commands.values()::contains);
|
||||
// Not sure if this is needed, but it clears out all references
|
||||
commands.values().forEach(c -> c.unregister(commandMap));
|
||||
|
@ -64,10 +64,8 @@ public class Converter {
|
||||
.map(this::convertLegacyEntity)
|
||||
// Collect into a map
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
if (le != null) {
|
||||
bp.setEntities(le);
|
||||
}
|
||||
}
|
||||
// Attached blocks
|
||||
if (bc.isConfigurationSection(ATTACHED_YAML_PREFIX)) {
|
||||
bp.setAttached(bc.getConfigurationSection(ATTACHED_YAML_PREFIX).getKeys(false).stream()
|
||||
|
@ -67,9 +67,9 @@ import world.bentobox.bentobox.util.Util;
|
||||
@PrepareForTest( {BentoBox.class, Flags.class, Util.class, Bukkit.class} )
|
||||
public class TNTListenerTest {
|
||||
|
||||
private static Location location;
|
||||
private static BentoBox plugin;
|
||||
private static Notifier notifier;
|
||||
private Location location;
|
||||
private BentoBox plugin;
|
||||
private Notifier notifier;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
Loading…
Reference in New Issue
Block a user