Javadoc and other cleanup from code analysis (#2099)

This commit is contained in:
tastybento 2023-02-26 17:48:37 -08:00 committed by GitHub
parent f02b4d5011
commit 2c283ae3a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
148 changed files with 264 additions and 703 deletions

View File

@ -3,7 +3,7 @@
* <p>
* Addons can expose data that they want to expose. To access it, call this class with the appropriate addon name,
* the label for the data that is requested and if required, a map of key-value pairs that will be given to the addon.
*
* <p>
* <b>Note</b> Since BentoBox 1.17.0, Addons can be declared as Pladdons and be loaded by the Bukkit classloader. This
* enables Plugins to access Addon methods directly so this API is not required.
* </p>

View File

@ -163,7 +163,7 @@ public class BentoBoxLocale {
/**
* Returns the list of prefixes available in this locale.
* @return list of prefixes available in this locale.
* @return Set of prefixes available in this locale.
* @since 1.13.0
*/
@NonNull

View File

@ -206,7 +206,6 @@ public class User implements MetaDataAble {
/**
* Get the user's inventory
* @return player's inventory
* @throws {@link NullPointerException} - if user is not a player
*/
@NonNull
public PlayerInventory getInventory() {
@ -216,7 +215,6 @@ public class User implements MetaDataAble {
/**
* Get the user's location
* @return location
* @throws {@link NullPointerException} - if user is not a player
*/
@NonNull
public Location getLocation() {
@ -252,7 +250,6 @@ public class User implements MetaDataAble {
* Use {@link #isOfflinePlayer()} before calling this method
* @return the offline player
* @since 1.3.0
* @throws {@link NullPointerException} - if user is not an offline player
*/
@NonNull
public OfflinePlayer getOfflinePlayer() {
@ -580,7 +577,6 @@ public class User implements MetaDataAble {
/**
* Gets the current world this entity resides in
* @return World - world
* @throws {@link NullPointerException} - if user is not a player
*/
@NonNull
public World getWorld() {

View File

@ -1,6 +1,6 @@
/**
* This package contains non-API classes that handle Blueprints.
*
* <p>
* Blueprints are BentoBox's version of schematics, but contain
* additional useful info.
*

View File

@ -85,7 +85,7 @@ public class Database<T> {
/**
* Save object async. Saving may be done sync, depending on the underlying database.
* @param instance to save
* @return true if no immediate errors. If async, errors may occur later.
* @return Completable future that results in true if successful.
* @since 1.13.0
*/
public CompletableFuture<Boolean> saveObjectAsync(T instance) {

View File

@ -724,7 +724,6 @@ public class Island implements DataObject, MetaDataAble {
* @param location - location
* @return true if in island space
*/
@SuppressWarnings("ConstantConditions")
public boolean inIslandSpace(Location location) {
return Util.sameWorld(this.world, location.getWorld()) &&
(location.getWorld().getEnvironment().equals(Environment.NORMAL) ||
@ -747,7 +746,6 @@ public class Island implements DataObject, MetaDataAble {
* @return a {@link BoundingBox} of the full island space.
* @since 1.5.2
*/
@SuppressWarnings("ConstantConditions")
@NonNull
public BoundingBox getBoundingBox() {
return this.getBoundingBox(Environment.NORMAL);
@ -778,7 +776,6 @@ public class Island implements DataObject, MetaDataAble {
else if (Environment.THE_END.equals(environment) && this.isEndIslandEnabled())
{
// If end world is generated, return end island bounding box.
//noinspection ConstantConditions
boundingBox = new BoundingBox(this.getMinX(),
this.getEndWorld().getMinHeight(),
this.getMinZ(),
@ -789,7 +786,6 @@ public class Island implements DataObject, MetaDataAble {
else if (Environment.NETHER.equals(environment) && this.isNetherIslandEnabled())
{
// If nether world is generated, return nether island bounding box.
//noinspection ConstantConditions
boundingBox = new BoundingBox(this.getMinX(),
this.getNetherWorld().getMinHeight(),
this.getMinZ(),
@ -909,7 +905,6 @@ public class Island implements DataObject, MetaDataAble {
* @param target location to check, not null
* @return {@code true} if this location is within this island's protected area, {@code false} otherwise.
*/
@SuppressWarnings("ConstantConditions")
public boolean onIsland(@NonNull Location target) {
return Util.sameWorld(this.world, target.getWorld()) &&
(target.getWorld().getEnvironment().equals(Environment.NORMAL) ||
@ -926,7 +921,6 @@ public class Island implements DataObject, MetaDataAble {
* @return a {@link BoundingBox} of this island's protected area.
* @since 1.5.2
*/
@SuppressWarnings("ConstantConditions")
@NonNull
public BoundingBox getProtectionBoundingBox() {
return this.getProtectionBoundingBox(Environment.NORMAL);
@ -958,7 +952,6 @@ public class Island implements DataObject, MetaDataAble {
else if (Environment.THE_END.equals(environment) && this.isEndIslandEnabled())
{
// If end world is generated, return end island bounding box.
//noinspection ConstantConditions
boundingBox = new BoundingBox(this.getMinProtectedX(),
this.getEndWorld().getMinHeight(),
this.getMinProtectedZ(),
@ -969,7 +962,6 @@ public class Island implements DataObject, MetaDataAble {
else if (Environment.NETHER.equals(environment) && this.isNetherIslandEnabled())
{
// If nether world is generated, return nether island bounding box.
//noinspection ConstantConditions
boundingBox = new BoundingBox(this.getMinProtectedX(),
this.getNetherWorld().getMinHeight(),
this.getMinProtectedZ(),

View File

@ -119,7 +119,7 @@ public class Players implements DataObject, MetaDataAble {
/**
* @param world - world
* @return List of home locations
* @return Map of home locations
* @deprecated Homes are stored in the island object now
*/
@Deprecated(since="1.18.0", forRemoval=true)

View File

@ -225,7 +225,7 @@ public class SQLDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T>
* Return the object decoded from JSON or null if there is an error
* @param uniqueId - unique Id of object used in error reporting
* @param preparedStatement - database statement to execute
* @return
* @return T
*/
private T getObject(@NonNull String uniqueId, PreparedStatement preparedStatement) {
try (ResultSet resultSet = preparedStatement.executeQuery())

View File

@ -91,7 +91,7 @@ public class LangUtilsHook extends Hook {
/**
* Get the item display name.
*
* <p>
* If the item contains a custom name, return its custom name.
* If the item itself does not have a custom name, the material
* name will be translated and returned.
@ -515,29 +515,74 @@ public class LangUtilsHook extends Hook {
int variant = (pcol & 255) << 24 | (bcol & 255) << 16 | (patt & 255) << 8 | type;
switch (variant) {
case 117506305: return "Anemone";
case 117899265: return "Black Tang";
case 185008129: return "Blue Tang";
case 117441793: return "Butterflyfish";
case 118161664: return "Cichlid";
case 65536 : return "Clownfish";
case 50726144 : return "Cotton Candy Betta";
case 67764993 : return "Dottyback";
case 234882305: return "Emperor Red Snapper";
case 67110144 : return "Goatfish";
case 117441025: return "Moorish Idol";
case 16778497 : return "Ornate Butterflyfish";
case 101253888: return "Parrotfish";
case 50660352 : return "Queen Angelfish";
case 918529 : return "Red Cichlid";
case 235340288: return "Red Lipped Blenny";
case 918273 : return "Red Snapper";
case 67108865 : return "Threadfin";
case 917504 : return "Tomato Clownfish";
case 459008 : return "Triggerfish";
case 67699456 : return "Yellowtail Parrotfish";
case 67371009 : return "Yellow Tang";
default : break;
case 117506305 -> {
return "Anemone";
}
case 117899265 -> {
return "Black Tang";
}
case 185008129 -> {
return "Blue Tang";
}
case 117441793 -> {
return "Butterflyfish";
}
case 118161664 -> {
return "Cichlid";
}
case 65536 -> {
return "Clownfish";
}
case 50726144 -> {
return "Cotton Candy Betta";
}
case 67764993 -> {
return "Dottyback";
}
case 234882305 -> {
return "Emperor Red Snapper";
}
case 67110144 -> {
return "Goatfish";
}
case 117441025 -> {
return "Moorish Idol";
}
case 16778497 -> {
return "Ornate Butterflyfish";
}
case 101253888 -> {
return "Parrotfish";
}
case 50660352 -> {
return "Queen Angelfish";
}
case 918529 -> {
return "Red Cichlid";
}
case 235340288 -> {
return "Red Lipped Blenny";
}
case 918273 -> {
return "Red Snapper";
}
case 67108865 -> {
return "Threadfin";
}
case 917504 -> {
return "Tomato Clownfish";
}
case 459008 -> {
return "Triggerfish";
}
case 67699456 -> {
return "Yellowtail Parrotfish";
}
case 67371009 -> {
return "Yellow Tang";
}
default -> {
}
}
}
return null;

View File

@ -65,7 +65,8 @@ public class BannedCommands implements Listener {
if (bannedSplit.length <= args.length) {
for (int i = 0; i < bannedSplit.length; i++) {
if (!bannedSplit[i].equals(args[i])) {
banned = false;
banned = false;
break;
}
}
}

View File

@ -34,11 +34,11 @@ public class GeoMobLimitTab implements Tab, ClickHandler {
/**
* A list of all living entity types, minus some
*/
private static final List<EntityType> LIVING_ENTITY_TYPES = Collections.unmodifiableList(Arrays.stream(EntityType.values())
private static final List<EntityType> LIVING_ENTITY_TYPES = Arrays.stream(EntityType.values())
.filter(EntityType::isAlive)
.filter(t -> !(t.equals(EntityType.PLAYER) || t.equals(EntityType.GIANT) || t.equals(EntityType.ARMOR_STAND)))
.sorted(Comparator.comparing(EntityType::name))
.toList());
.toList();
public enum EntityLimitTabType {
GEO_LIMIT,

View File

@ -32,7 +32,7 @@ public class BreedingListener extends FlagListener {
/**
* A list of items that cause breeding if a player has them in their hand and they click an animal
* This list may need to be extended with future versions of Minecraft.
* See this Minecraft Wiki page for reference: https://minecraft.gamepedia.com/Breeding#Breeding_foods.
* See this Minecraft Wiki page for reference: <a href="https://minecraft.gamepedia.com/Breeding#Breeding_foods">...</a>.
*/
private static final Map<EntityType, List<Material>> BREEDING_ITEMS;
static {

View File

@ -135,7 +135,7 @@ public class LockAndBanListener extends FlagListener {
* Checks if a player is banned from this location and notifies them if so
* @param player - player
* @param loc - location to check
* @return true if banned
* @return CheckResult
*/
private CheckResult checkAndNotify(@NonNull Player player, Location loc)
{

View File

@ -51,10 +51,10 @@ public class EntityTeleportListener extends AbstractTeleportListener implements
/**
* This listener checks entity portal events and triggers appropriate methods to transfer
* entities to the correct location in other dimension.
*
* <p>
* This event is triggered when entity is about to being teleported because of contact with the
* nether portal or end gateway portal (exit portal triggers respawn).
*
* <p>
* This event is not called if nether/end is disabled in server settings.
*
* @param event the entity portal event.

View File

@ -63,10 +63,10 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
/**
* This listener checks player portal events and triggers appropriate methods to transfer
* players to the correct location in other dimension.
*
* <p>
* This event is triggered when player is about to being teleported because of contact with the
* nether portal or end gateway portal (exit portal triggers respawn).
*
* <p>
* This event is not called if nether/end is disabled in server settings.
*
* @param event the player portal event.

View File

@ -346,7 +346,6 @@ public class AddonsManager {
/**
* Create seed worlds, which are used for deletion
* @param gameMode
*/
private void createSeedWorlds(GameModeAddon gameMode) {
if (gameMode.getOverWorld() != null) {

View File

@ -120,7 +120,7 @@ public class LocalesManager {
/**
* Gets the list of prefixes from the user's locale, the server's locale and the en-US locale file.
* @param user the user to get the locale, not null.
* @return the list of prefixes from the user's locale, the server's locale and the en-US locale file.
* @return the set of prefixes from the user's locale, the server's locale and the en-US locale file.
* @since 1.13.0
*/
public Set<String> getAvailablePrefixes(@NonNull User user) {

View File

@ -284,7 +284,7 @@ public class PlayersManager {
/**
* Provides all home locations for player
* @param playerUUID - the player's UUID
* @return List of home locations
* @return Map of home locations
* @deprecated Use {@link IslandsManager#getHomeLocations(world.bentobox.bentobox.database.objects.Island)}
*/
@Deprecated(since="1.18.0", forRemoval=true)

View File

@ -70,7 +70,7 @@ public class DefaultNewIslandLocationStrategy implements NewIslandLocationStrate
* Checks if there is an island or blocks at this location
*
* @param location - the location
* @return Result enum if island found, null if blocks found, false if nothing found
* @return Result enum indicated what was found or not found
*/
protected Result isIsland(Location location) {
// Quick check

View File

@ -18,22 +18,18 @@ public class MyBiomeGrid implements BiomeGrid {
Map<Vector, Biome> map = new HashMap<>();
private Biome defaultBiome;
public MyBiomeGrid(Environment environment) {
switch(environment) {
case NETHER:
try {
// 1.16 onwards
defaultBiome = Biome.valueOf("NETHER_WASTES");
} catch (Exception e) {
// Before 1.16
defaultBiome = Biome.valueOf("NETHER");
switch (environment) {
case NETHER -> {
try {
// 1.16 onwards
defaultBiome = Biome.valueOf("NETHER_WASTES");
} catch (Exception e) {
// Before 1.16
defaultBiome = Biome.valueOf("NETHER");
}
}
break;
case THE_END:
defaultBiome = Biome.THE_END;
break;
default:
defaultBiome = Biome.PLAINS;
break;
case THE_END -> defaultBiome = Biome.THE_END;
default -> defaultBiome = Biome.PLAINS;
}
}

View File

@ -467,7 +467,7 @@ public class Util {
/**
* Detects if the current MC version is at least the following version.
*
* <p>
* Assumes 0 patch version.
*
* @param minor Min Minor Version

View File

@ -276,7 +276,7 @@ public class ClosestSafeSpotTeleport
/**
* This method finishes the chunk loading task and checks from all remaining positions in block queue
* to find the best location for teleportation.
*
* <p>
* This method stops position finding task and process teleporation.
*/
private void finishTask()

View File

@ -28,7 +28,6 @@ public class SettingsTest {
private Settings s;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -49,7 +49,7 @@ import world.bentobox.bentobox.managers.AddonsManager;
@PrepareForTest( { BentoBox.class, Bukkit.class })
public class AddonClassLoaderTest {
private enum MandatoryTags {
private enum mandatoryTags {
MAIN,
NAME,
VERSION,
@ -76,7 +76,6 @@ public class AddonClassLoaderTest {
private BentoBox plugin;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -91,7 +90,7 @@ public class AddonClassLoaderTest {
}
public void makeAddon(List<MandatoryTags> missingTags) throws IOException {
public void makeAddon(List<mandatoryTags> missingTags) throws IOException {
// Make the addon
dataFolder = new File("dataFolder");
jarFile = new File("addon.jar");
@ -112,18 +111,18 @@ public class AddonClassLoaderTest {
Files.deleteIfExists(ymlFile.toPath());
}
private YamlConfiguration getYaml(List<MandatoryTags> missingTags) {
private YamlConfiguration getYaml(List<mandatoryTags> missingTags) {
YamlConfiguration r = new YamlConfiguration();
if (!missingTags.contains(MandatoryTags.NAME)) {
if (!missingTags.contains(mandatoryTags.NAME)) {
r.set("name", "TestAddon");
}
if (!missingTags.contains(MandatoryTags.MAIN)) {
if (!missingTags.contains(mandatoryTags.MAIN)) {
r.set("main", "world.bentobox.test.Test");
}
if (!missingTags.contains(MandatoryTags.VERSION)) {
if (!missingTags.contains(mandatoryTags.VERSION)) {
r.set("version", "1.0.0");
}
if (!missingTags.contains(MandatoryTags.AUTHORS)) {
if (!missingTags.contains(mandatoryTags.AUTHORS)) {
r.set("authors", "tastybento");
}
r.set("metrics", false);
@ -174,7 +173,6 @@ public class AddonClassLoaderTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void TearDown() throws IOException {
@ -199,7 +197,6 @@ public class AddonClassLoaderTest {
/**
* Test method for {@link world.bentobox.bentobox.api.addons.AddonClassLoader#AddonClassLoader(world.bentobox.bentobox.managers.AddonsManager, org.bukkit.configuration.file.YamlConfiguration, java.io.File, java.lang.ClassLoader)}.
* @throws MalformedURLException
*/
@Test
public void testAddonClassLoader() throws MalformedURLException {
@ -208,7 +205,6 @@ public class AddonClassLoaderTest {
/**
* Test method for {@link world.bentobox.bentobox.api.addons.AddonClassLoader#asDescription(org.bukkit.configuration.file.YamlConfiguration)}.
* @throws InvalidAddonDescriptionException
*/
@Test
public void testAsDescription() throws InvalidAddonDescriptionException {
@ -232,11 +228,10 @@ public class AddonClassLoaderTest {
/**
* Test method for {@link world.bentobox.bentobox.api.addons.AddonClassLoader#asDescription(org.bukkit.configuration.file.YamlConfiguration)}.
* @throws InvalidAddonDescriptionException
*/
@Test
public void testAsDescriptionNoName() {
YamlConfiguration yml = this.getYaml(List.of(MandatoryTags.NAME));
YamlConfiguration yml = this.getYaml(List.of(mandatoryTags.NAME));
try {
AddonClassLoader.asDescription(yml);
} catch (InvalidAddonDescriptionException e) {
@ -246,11 +241,10 @@ public class AddonClassLoaderTest {
/**
* Test method for {@link world.bentobox.bentobox.api.addons.AddonClassLoader#asDescription(org.bukkit.configuration.file.YamlConfiguration)}.
* @throws InvalidAddonDescriptionException
*/
@Test
public void testAsDescriptionNoAuthors() {
YamlConfiguration yml = this.getYaml(List.of(MandatoryTags.AUTHORS));
YamlConfiguration yml = this.getYaml(List.of(mandatoryTags.AUTHORS));
try {
AddonClassLoader.asDescription(yml);
} catch (InvalidAddonDescriptionException e) {
@ -260,11 +254,10 @@ public class AddonClassLoaderTest {
/**
* Test method for {@link world.bentobox.bentobox.api.addons.AddonClassLoader#asDescription(org.bukkit.configuration.file.YamlConfiguration)}.
* @throws InvalidAddonDescriptionException
*/
@Test
public void testAsDescriptionNoVersion() {
YamlConfiguration yml = this.getYaml(List.of(MandatoryTags.VERSION));
YamlConfiguration yml = this.getYaml(List.of(mandatoryTags.VERSION));
try {
AddonClassLoader.asDescription(yml);
} catch (InvalidAddonDescriptionException e) {
@ -274,11 +267,10 @@ public class AddonClassLoaderTest {
/**
* Test method for {@link world.bentobox.bentobox.api.addons.AddonClassLoader#asDescription(org.bukkit.configuration.file.YamlConfiguration)}.
* @throws InvalidAddonDescriptionException
*/
@Test
public void testAsDescriptionNoMain() {
YamlConfiguration yml = this.getYaml(List.of(MandatoryTags.MAIN));
YamlConfiguration yml = this.getYaml(List.of(mandatoryTags.MAIN));
try {
AddonClassLoader.asDescription(yml);
} catch (InvalidAddonDescriptionException e) {
@ -288,7 +280,6 @@ public class AddonClassLoaderTest {
/**
* Test method for {@link world.bentobox.bentobox.api.addons.AddonClassLoader#findClass(java.lang.String)}.
* @throws MalformedURLException
*/
@Test
public void testFindClassString() throws MalformedURLException {
@ -299,7 +290,6 @@ public class AddonClassLoaderTest {
/**
* Test method for {@link world.bentobox.bentobox.api.addons.AddonClassLoader#findClass(java.lang.String, boolean)}.
* @throws MalformedURLException
*/
@Test
public void testFindClassStringBoolean() throws MalformedURLException {
@ -310,7 +300,6 @@ public class AddonClassLoaderTest {
/**
* Test method for {@link world.bentobox.bentobox.api.addons.AddonClassLoader#getAddon()}.
* @throws MalformedURLException
*/
@Test
public void testGetAddon() throws MalformedURLException {
@ -321,7 +310,6 @@ public class AddonClassLoaderTest {
/**
* Test method for {@link world.bentobox.bentobox.api.addons.AddonClassLoader#getClasses()}.
* @throws MalformedURLException
*/
@Test
public void testGetClasses() throws MalformedURLException {

View File

@ -24,7 +24,6 @@ public class AddonDescriptionTest {
private ConfigurationSection configSec;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -39,7 +39,6 @@ public class DefaultHelpCommandTest {
private User user;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -80,7 +80,6 @@ public class DelayedTeleportCommandTest {
private Notifier notifier;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -45,7 +45,6 @@ public class HiddenCommandTest {
private User user;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -57,7 +57,6 @@ public class AdminDeleteCommandTest {
private UUID uuid;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -71,7 +71,6 @@ public class AdminGetrankCommandTest {
private Island island;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -99,12 +98,12 @@ public class AdminGetrankCommandTest {
Map<UUID, String> online = new HashMap<>();
Set<Player> onlinePlayers = new HashSet<>();
for (int j = 0; j < NAMES.length; j++) {
for (String name : NAMES) {
Player p1 = mock(Player.class);
UUID uuid = UUID.randomUUID();
when(p1.getUniqueId()).thenReturn(uuid);
when(p1.getName()).thenReturn(NAMES[j]);
online.put(uuid, NAMES[j]);
when(p1.getName()).thenReturn(name);
online.put(uuid, name);
onlinePlayers.add(p1);
}
PowerMockito.mockStatic(Bukkit.class);
@ -115,7 +114,6 @@ public class AdminGetrankCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {
@ -221,15 +219,11 @@ public class AdminGetrankCommandTest {
public void testTabCompleteUserStringListOfStringWithChars() {
Optional<List<String>> result = c.tabComplete(user, "", Collections.singletonList("g"));
assertTrue(result.isPresent());
result.ifPresent(list -> {
assertEquals(1, list.size());
});
result.ifPresent(list -> assertEquals(1, list.size()));
// Two names
result = c.tabComplete(user, "", Collections.singletonList("f"));
assertTrue(result.isPresent());
result.ifPresent(list -> {
assertEquals(2, list.size());
});
result.ifPresent(list -> assertEquals(2, list.size()));
}
}

View File

@ -81,7 +81,6 @@ public class AdminInfoCommandTest {
private IslandWorldManager iwm;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -141,7 +140,6 @@ public class AdminInfoCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -68,7 +68,6 @@ public class AdminRegisterCommandTest {
private IslandDeletionManager idm;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -78,7 +78,6 @@ public class AdminResetFlagsCommandTest {
private @Nullable User user;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -140,7 +139,6 @@ public class AdminResetFlagsCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -63,7 +63,6 @@ public class AdminSetrankCommandTest {
private UUID targetUUID;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -106,7 +105,6 @@ public class AdminSetrankCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -52,7 +52,6 @@ public class AdminSetspawnCommandTest {
private IslandsManager im;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -93,7 +93,6 @@ public class AdminSettingsCommandTest {
private PluginManager pluginManager;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -187,7 +186,6 @@ public class AdminSettingsCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {

View File

@ -50,7 +50,6 @@ public class AdminSwitchCommandTest {
private UUID notUUID;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -85,7 +84,6 @@ public class AdminSwitchCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {

View File

@ -78,7 +78,6 @@ public class AdminTeleportCommandTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -142,12 +141,7 @@ public class AdminTeleportCommandTest {
when(lm.get(any(), any())).thenReturn("mock translation");
when(plugin.getLocalesManager()).thenReturn(lm);
when(user.getTranslation(Mockito.anyString(),Mockito.anyString(), Mockito.anyString())).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArgument(0, String.class);
}});
when(user.getTranslation(Mockito.anyString(),Mockito.anyString(), Mockito.anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
// Island location
Location location = mock(Location.class);

View File

@ -65,7 +65,6 @@ public class AdminUnregisterCommandTest {
private UUID notUUID;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -61,7 +61,6 @@ public class AdminBlueprintCopyCommandTest {
private AdminBlueprintCopyCommand abcc;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -111,7 +110,6 @@ public class AdminBlueprintCopyCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {

View File

@ -60,7 +60,6 @@ public class AdminBlueprintDeleteCommandTest {
private Map<String, Blueprint> map;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -107,7 +106,6 @@ public class AdminBlueprintDeleteCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {

View File

@ -33,7 +33,6 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.blueprints.Blueprint;
import world.bentobox.bentobox.managers.BlueprintsManager;
@ -65,7 +64,6 @@ public class AdminBlueprintLoadCommandTest {
private File blueprintsFolder;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -118,7 +116,6 @@ public class AdminBlueprintLoadCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {

View File

@ -66,7 +66,6 @@ public class AdminBlueprintSaveCommandTest {
private Blueprint bp = new Blueprint();
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -115,7 +114,6 @@ public class AdminBlueprintSaveCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {

View File

@ -54,7 +54,6 @@ public class AdminBlueprintsListCommandTest {
private File dataFolder;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -97,7 +96,6 @@ public class AdminBlueprintsListCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
@ -157,7 +155,6 @@ public class AdminBlueprintsListCommandTest {
/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.blueprints.AdminBlueprintListCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
* @throws IOException
*/
@Test
public void testExecuteUserStringListOfStringNoBlueprintsFiles() throws IOException {
@ -170,7 +167,6 @@ public class AdminBlueprintsListCommandTest {
/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.blueprints.AdminBlueprintListCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
* @throws IOException
*/
@Test
public void testExecuteUserStringListOfStringWithBlueprintsFiles() throws IOException {

View File

@ -71,7 +71,6 @@ public class AdminPurgeCommandTest {
private PlayersManager pm;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -58,7 +58,6 @@ public class AdminPurgeUnownedCommandTest {
private World world;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -43,7 +43,6 @@ public class AdminRangeCommandTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -44,7 +44,6 @@ public class AdminRangeDisplayCommandTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -59,7 +59,6 @@ public class AdminRangeResetCommandTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -59,7 +59,6 @@ public class AdminRangeSetCommandTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -58,7 +58,6 @@ public class AdminTeamAddCommandTest {
private UUID notUUID;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -74,7 +74,6 @@ public class AdminTeamDisbandCommandTest {
private UUID notUUID;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -71,7 +71,6 @@ public class AdminTeamKickCommandTest {
private PluginManager pim;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -63,7 +63,6 @@ public class AdminTeamSetownerCommandTest {
private UUID notUUID;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -66,7 +66,6 @@ public class IslandBanlistCommandTest {
private Island island;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -77,7 +77,6 @@ public class IslandCreateCommandTest {
private BlueprintsManager bpm;
/**
* @throws java.lang.Exception
*/
@SuppressWarnings("deprecation")
@Before
@ -160,7 +159,6 @@ public class IslandCreateCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {
@ -230,7 +228,6 @@ public class IslandCreateCommandTest {
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandCreateCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
* @throws IOException
*/
@Test
public void testExecuteUserStringListOfStringSuccess() throws Exception {
@ -250,7 +247,6 @@ public class IslandCreateCommandTest {
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandCreateCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
* @throws IOException
*/
@Test
public void testExecuteUserStringListOfStringThrowException() throws Exception {
@ -302,7 +298,6 @@ public class IslandCreateCommandTest {
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandCreateCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
* @throws IOException
*/
@Test
public void testExecuteUserStringListOfStringKnownBundle() throws Exception {

View File

@ -166,7 +166,6 @@ public class IslandExpelCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -92,7 +92,6 @@ public class IslandGoCommandTest {
private @Nullable WorldSettings ws;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -67,7 +67,6 @@ public class IslandHomesCommandTest {
private IslandWorldManager iwm;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -81,7 +81,6 @@ public class IslandInfoCommandTest {
private IslandWorldManager iwm;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -141,7 +140,6 @@ public class IslandInfoCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -85,7 +85,6 @@ public class IslandNearCommandTest {
private Block block;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -160,7 +159,6 @@ public class IslandNearCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -94,7 +94,6 @@ public class IslandResetCommandTest {
private UUID uuid;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -66,7 +66,6 @@ public class IslandSethomeCommandTest {
private WorldSettings ws;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -81,7 +81,6 @@ public class IslandSpawnCommandTest {
private Settings s;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -149,7 +148,6 @@ public class IslandSpawnCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -68,7 +68,6 @@ public class IslandUnbanCommandTest {
private Island island;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -78,7 +78,6 @@ public class IslandTeamCommandTest {
private @Nullable Island island;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -132,7 +131,6 @@ public class IslandTeamCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {

View File

@ -68,7 +68,6 @@ public class IslandTeamCoopCommandTest {
private Island island;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -74,7 +74,6 @@ public class IslandTeamInviteAcceptCommandTest {
private Invite invite;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -153,7 +152,6 @@ public class IslandTeamInviteAcceptCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {

View File

@ -78,7 +78,6 @@ public class IslandTeamInviteCommandTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -88,7 +88,6 @@ public class IslandTeamKickCommandTest {
private Addon addon;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -68,7 +68,6 @@ public class IslandTeamLeaveCommandTest {
private World world;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -73,7 +73,6 @@ public class IslandTeamSetownerCommandTest {
private IslandTeamSetownerCommand its;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -135,7 +134,6 @@ public class IslandTeamSetownerCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {

View File

@ -71,7 +71,6 @@ public class IslandTeamTrustCommandTest {
private Player targetPlayer;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -64,7 +64,6 @@ public class IslandTeamUncoopCommandTest {
private Island island;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -63,7 +63,6 @@ public class IslandTeamUntrustCommandTest {
private Island island;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -28,7 +28,6 @@ public class AddonEnableEventTest {
private Addon addon;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -49,7 +49,6 @@ public class IslandEventTest {
private PluginManager pim;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -64,7 +63,6 @@ public class IslandEventTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
@ -103,69 +101,28 @@ public class IslandEventTest {
.build();
e = e.getNewEvent().orElse(e);
switch (reason) {
case BAN:
assertTrue(e instanceof IslandBanEvent);
break;
case CREATE:
assertTrue(e instanceof IslandCreateEvent);
break;
case CREATED:
assertTrue(e instanceof IslandCreatedEvent);
break;
case DELETE:
assertTrue(e instanceof IslandDeleteEvent);
break;
case DELETED:
assertTrue(e instanceof IslandDeletedEvent);
break;
case DELETE_CHUNKS:
assertTrue(e instanceof IslandDeleteChunksEvent);
break;
case ENTER:
assertTrue(e instanceof IslandEnterEvent);
break;
case EXIT:
assertTrue(e instanceof IslandExitEvent);
break;
case EXPEL:
assertTrue(e instanceof IslandExpelEvent);
break;
case LOCK:
assertTrue(e instanceof IslandLockEvent);
break;
case PRECLEAR:
assertTrue(e instanceof IslandPreclearEvent);
break;
case RANGE_CHANGE:
assertTrue(e instanceof IslandProtectionRangeChangeEvent);
break;
case REGISTERED:
assertTrue(e instanceof IslandRegisteredEvent);
break;
case RESERVED:
assertTrue(e instanceof IslandReservedEvent);
break;
case RESET:
assertTrue(e instanceof IslandResetEvent);
break;
case RESETTED:
assertTrue(e instanceof IslandResettedEvent);
break;
case UNBAN:
assertTrue(e instanceof IslandUnbanEvent);
break;
case UNKNOWN:
assertTrue(e instanceof IslandGeneralEvent);
break;
case UNLOCK:
assertTrue(e instanceof IslandUnlockEvent);
break;
case UNREGISTERED:
assertTrue(e instanceof IslandUnregisteredEvent);
break;
default:
break;
case BAN -> assertTrue(e instanceof IslandBanEvent);
case CREATE -> assertTrue(e instanceof IslandCreateEvent);
case CREATED -> assertTrue(e instanceof IslandCreatedEvent);
case DELETE -> assertTrue(e instanceof IslandDeleteEvent);
case DELETED -> assertTrue(e instanceof IslandDeletedEvent);
case DELETE_CHUNKS -> assertTrue(e instanceof IslandDeleteChunksEvent);
case ENTER -> assertTrue(e instanceof IslandEnterEvent);
case EXIT -> assertTrue(e instanceof IslandExitEvent);
case EXPEL -> assertTrue(e instanceof IslandExpelEvent);
case LOCK -> assertTrue(e instanceof IslandLockEvent);
case PRECLEAR -> assertTrue(e instanceof IslandPreclearEvent);
case RANGE_CHANGE -> assertTrue(e instanceof IslandProtectionRangeChangeEvent);
case REGISTERED -> assertTrue(e instanceof IslandRegisteredEvent);
case RESERVED -> assertTrue(e instanceof IslandReservedEvent);
case RESET -> assertTrue(e instanceof IslandResetEvent);
case RESETTED -> assertTrue(e instanceof IslandResettedEvent);
case UNBAN -> assertTrue(e instanceof IslandUnbanEvent);
case UNKNOWN -> assertTrue(e instanceof IslandGeneralEvent);
case UNLOCK -> assertTrue(e instanceof IslandUnlockEvent);
case UNREGISTERED -> assertTrue(e instanceof IslandUnregisteredEvent);
default -> {
}
}
}
verify(pim, Mockito.times(Reason.values().length * 2)).callEvent(any());

View File

@ -68,7 +68,6 @@ public class FlagTest {
private BentoBox plugin;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -102,7 +101,6 @@ public class FlagTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -64,7 +64,6 @@ public class IslandToggleClickTest {
private SettingsTab settingsTab;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -53,7 +53,6 @@ public class WorldToggleClickTest {
private PluginManager pim;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -42,7 +42,6 @@ public class BentoBoxLocaleTest {
private BannerMeta bannerMeta;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -57,7 +57,6 @@ public class PanelTest {
private Inventory inv;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -78,7 +77,6 @@ public class PanelTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -34,7 +34,6 @@ import world.bentobox.bentobox.api.user.User;
public class PanelBuilderTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -18,7 +18,6 @@ public class NotifierTest {
private Notifier n;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -26,7 +25,6 @@ public class NotifierTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {
@ -61,7 +59,6 @@ public class NotifierTest {
/**
* Test method for {@link world.bentobox.bentobox.api.user.Notifier#notify(world.bentobox.bentobox.api.user.User, java.lang.String)}.
* @throws InterruptedException
*/
@Test
public void testNotifyUserStringMultisendWaitSend() throws InterruptedException {

View File

@ -56,7 +56,6 @@ public class BlueprintPasterTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -56,7 +56,6 @@ public class BentoBoxReloadCommandTest {
private BentoBoxReloadCommand reload;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -106,7 +105,6 @@ public class BentoBoxReloadCommandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -60,7 +60,6 @@ public class DatabaseTest {
private Island island;
/**
* @throws java.lang.Exception
*/
@SuppressWarnings("unchecked")
@Before
@ -91,7 +90,6 @@ public class DatabaseTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
@ -101,7 +99,6 @@ public class DatabaseTest {
/**
* Check if logger logged a severe string
* @param stringToCheck
*/
private void checkSevereLog(String stringToCheck) {
// This magic obtains the lambda from an argument
@ -114,7 +111,7 @@ public class DatabaseTest {
*/
@Test
public void testDatabaseBentoBoxClassOfT() {
new Database<Island>(plugin, Island.class);
new Database<>(plugin, Island.class);
verify(plugin).getLogger();
verify(dbSetup).getHandler(any());
}
@ -124,40 +121,28 @@ public class DatabaseTest {
*/
@Test
public void testDatabaseAddonClassOfT() {
new Database<Island>(addon, Island.class);
new Database<>(addon, Island.class);
verify(addon).getLogger();
verify(dbSetup).getHandler(any());
}
/**
* Test method for {@link world.bentobox.bentobox.database.Database#loadObjects()}.
* @throws IntrospectionException
* @throws NoSuchMethodException
* @throws ClassNotFoundException
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws InstantiationException
*/
@Test
public void testLoadObjects() throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, NoSuchMethodException, IntrospectionException {
Database<Island> db = new Database<Island>(plugin, Island.class);
Database<Island> db = new Database<>(plugin, Island.class);
assertEquals(objectList, db.loadObjects());
verify(handler).loadObjects();
}
/**
* Test method for {@link world.bentobox.bentobox.database.Database#loadObjects()}.
* @throws IntrospectionException
* @throws NoSuchMethodException
* @throws ClassNotFoundException
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws InstantiationException
*/
@Test
public void testLoadObjectsThrowException() throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, NoSuchMethodException, IntrospectionException {
when(handler.loadObjects()).thenThrow(new IllegalAccessException("No bad dog! No biscuit!"));
Database<Island> db = new Database<Island>(plugin, Island.class);
Database<Island> db = new Database<>(plugin, Island.class);
db.loadObjects();
verify(handler).loadObjects();
checkSevereLog("Could not load objects from database! Error: No bad dog! No biscuit!");
@ -166,16 +151,10 @@ public class DatabaseTest {
/**
* Test method for {@link world.bentobox.bentobox.database.Database#loadObject(java.lang.String)}.
* @throws IntrospectionException
* @throws NoSuchMethodException
* @throws ClassNotFoundException
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws InstantiationException
*/
@Test
public void testLoadObject() throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, NoSuchMethodException, IntrospectionException {
Database<Island> db = new Database<Island>(plugin, Island.class);
Database<Island> db = new Database<>(plugin, Island.class);
String uniqueId = UUID.randomUUID().toString();
assertEquals(island, db.loadObject(uniqueId));
verify(handler).loadObject(eq(uniqueId));
@ -183,13 +162,10 @@ public class DatabaseTest {
/**
* Test method for {@link world.bentobox.bentobox.database.Database#saveObject(java.lang.Object)}.
* @throws IntrospectionException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Test
public void testSaveObject() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
Database<Island> db = new Database<Island>(plugin, Island.class);
Database<Island> db = new Database<>(plugin, Island.class);
db.saveObjectAsync(island);
verify(handler).saveObject(eq(island));
@ -197,14 +173,11 @@ public class DatabaseTest {
/**
* Test method for {@link world.bentobox.bentobox.database.Database#saveObject(java.lang.Object)}.
* @throws IntrospectionException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Test
public void testSaveObjectException() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
doThrow(new IntrospectionException("No means no!")).when(handler).saveObject(any(Island.class));
Database<Island> db = new Database<Island>(plugin, Island.class);
Database<Island> db = new Database<>(plugin, Island.class);
db.saveObjectAsync(island);
checkSevereLog("Could not save object to database! Error: No means no!");
}
@ -216,7 +189,7 @@ public class DatabaseTest {
public void testObjectExists() {
when(handler.objectExists(eq("test"))).thenReturn(false);
when(handler.objectExists(eq("exists"))).thenReturn(true);
Database<Island> db = new Database<Island>(plugin, Island.class);
Database<Island> db = new Database<>(plugin, Island.class);
assertFalse(db.objectExists("test"));
assertTrue(db.objectExists("exists"));
}
@ -226,34 +199,28 @@ public class DatabaseTest {
*/
@Test
public void testDeleteID() {
Database<Island> db = new Database<Island>(plugin, Island.class);
Database<Island> db = new Database<>(plugin, Island.class);
db.deleteID("test");
verify(handler).deleteID(eq("test"));
}
/**
* Test method for {@link world.bentobox.bentobox.database.Database#deleteObject(java.lang.Object)}.
* @throws IntrospectionException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Test
public void testDeleteObject() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
Database<Island> db = new Database<Island>(plugin, Island.class);
Database<Island> db = new Database<>(plugin, Island.class);
db.deleteObject(island);
verify(handler).deleteObject(eq(island));
}
/**
* Test method for {@link world.bentobox.bentobox.database.Database#deleteObject(java.lang.Object)}.
* @throws IntrospectionException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Test
public void testDeleteObjectFail() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
doThrow(new IllegalArgumentException("Wot?!")).when(handler).deleteObject(any());
Database<Island> db = new Database<Island>(plugin, Island.class);
Database<Island> db = new Database<>(plugin, Island.class);
db.deleteObject(island);
checkSevereLog("Could not delete object! Error: Wot?!");
}
@ -264,7 +231,7 @@ public class DatabaseTest {
*/
@Test
public void testClose() {
Database<Island> db = new Database<Island>(plugin, Island.class);
Database<Island> db = new Database<>(plugin, Island.class);
db.close();
verify(handler).close();
}

View File

@ -64,7 +64,6 @@ public class ItemStackTypeAdapterTest {
private ItemFactory itemFactory;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -105,7 +104,6 @@ public class ItemStackTypeAdapterTest {
/**
* Test method for {@link world.bentobox.bentobox.database.json.adapters.ItemStackTypeAdapter#write(com.google.gson.stream.JsonWriter, org.bukkit.inventory.ItemStack)}.
* @throws IOException
*/
@Test
public void testWriteJsonWriterItemStack() throws IOException {
@ -118,7 +116,6 @@ public class ItemStackTypeAdapterTest {
/**
* Test method for {@link world.bentobox.bentobox.database.json.adapters.ItemStackTypeAdapter#write(com.google.gson.stream.JsonWriter, org.bukkit.inventory.ItemStack)}.
* @throws IOException
*/
@Test
public void testWriteJsonWriterItemStackNull() throws IOException {
@ -128,7 +125,6 @@ public class ItemStackTypeAdapterTest {
/**
* Test method for {@link world.bentobox.bentobox.database.json.adapters.ItemStackTypeAdapter#read(com.google.gson.stream.JsonReader)}.
* @throws IOException
*/
@Test
public void testReadJsonReaderNull() throws IOException {
@ -138,7 +134,6 @@ public class ItemStackTypeAdapterTest {
/**
* Test method for {@link world.bentobox.bentobox.database.json.adapters.ItemStackTypeAdapter#read(com.google.gson.stream.JsonReader)}.
* @throws IOException
*/
@Test
public void testReadJsonReader() throws IOException {
@ -164,7 +159,6 @@ public class ItemStackTypeAdapterTest {
/**
* Test method for {@link world.bentobox.bentobox.database.json.adapters.ItemStackTypeAdapter#read(com.google.gson.stream.JsonReader)}.
* @throws IOException
*/
@Test
public void testReadJsonReaderUnknownMaterial() throws IOException {

View File

@ -54,7 +54,6 @@ public class IslandDeletionTest {
private UUID uuid;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -76,7 +76,6 @@ public class IslandTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -112,7 +111,6 @@ public class IslandTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
@ -471,7 +469,7 @@ public class IslandTest {
*/
@Test
public void testInIslandSpacePairOfIntegerInteger() {
assertTrue(i.inIslandSpace(new Pair<Integer, Integer>(0,0)));
assertTrue(i.inIslandSpace(new Pair<>(0, 0)));
}
/**
@ -611,7 +609,7 @@ public class IslandTest {
*/
@Test
public void testSetFlagFlagIntBoolean() {
Flag f = Flags.values().stream().filter(fl -> fl.hasSubflags()).findFirst().orElse(null);
Flag f = Flags.values().stream().filter(Flag::hasSubflags).findFirst().orElse(null);
if (f != null) {
i.setFlag(f, 100, true);
assertTrue(i.isChanged());
@ -813,7 +811,7 @@ public class IslandTest {
*/
@Test
public void testToggleFlagFlagBoolean() {
Flag f = Flags.values().stream().filter(fl -> fl.hasSubflags())
Flag f = Flags.values().stream().filter(Flag::hasSubflags)
.filter(fl -> fl.getType().equals(Type.SETTING))
.findFirst().orElse(null);
if (f != null) {

View File

@ -45,7 +45,6 @@ public class PlayersTest {
private Players p;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -29,7 +29,6 @@ public class LogEntryListAdapterTest {
private List<LogEntry> toLog;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -42,7 +41,7 @@ public class LogEntryListAdapterTest {
toLog.add(new LogEntry.Builder("BAN").data("player", target.toString()).data("issuer", issuer.toString()).build());
toLog.add(new LogEntry.Builder("UNBAN").data("player", target.toString()).data("issuer", issuer.toString()).build());
toLog.add(new LogEntry.Builder("UNOWNED").build());
toLog.forEach(history::add);
history.addAll(toLog);
}
@After

View File

@ -42,7 +42,6 @@ public class MySQLDatabaseConnectorTest {
private Logger logger;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -57,7 +56,6 @@ public class MySQLDatabaseConnectorTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {
@ -87,7 +85,6 @@ public class MySQLDatabaseConnectorTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseConnector#createConnection()}.
* @throws SQLException
*/
@Ignore("Does not work in Java 11")
@Test

View File

@ -82,7 +82,6 @@ public class MySQLDatabaseHandlerTest {
@Mock
private Settings settings;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -126,7 +125,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#loadObjects()}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -138,7 +136,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#loadObjects()}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -156,7 +153,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#loadObjects()}.
* @throws SQLException
*/
@Test
@Ignore
@ -175,7 +171,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#loadObjects()}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -193,7 +188,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#loadObjects()}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -223,7 +217,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#loadObject(java.lang.String)}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -242,7 +235,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#loadObject(java.lang.String)}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -258,7 +250,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#loadObject(java.lang.String)}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -289,14 +280,13 @@ public class MySQLDatabaseHandlerTest {
@Ignore("After reworking to HikariCP, this does not work.")
public void testSaveObjectNotDataObject() {
@SuppressWarnings("rawtypes")
MySQLDatabaseHandler<List> h = new MySQLDatabaseHandler<List>(plugin, List.class, dbConn);
MySQLDatabaseHandler<List> h = new MySQLDatabaseHandler<>(plugin, List.class, dbConn);
h.saveObject(Collections.singletonList("test"));
verify(plugin).logError(eq("This class is not a DataObject: java.util.Collections$SingletonList"));
}
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#saveObject(java.lang.Object)}.
* @throws SQLException
*/
@Test
@Ignore("Async cannot be tested")
@ -328,7 +318,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#saveObject(java.lang.Object)}.
* @throws SQLException
*/
@Test
@Ignore("Async cannot be tested")
@ -358,14 +347,13 @@ public class MySQLDatabaseHandlerTest {
@Ignore("After reworking to HikariCP, this does not work.")
public void testDeleteObjectIncorrectType() {
@SuppressWarnings("rawtypes")
MySQLDatabaseHandler<List> h = new MySQLDatabaseHandler<List>(plugin, List.class, dbConn);
MySQLDatabaseHandler<List> h = new MySQLDatabaseHandler<>(plugin, List.class, dbConn);
h.deleteObject(Collections.singletonList("test"));
verify(plugin).logError(eq("This class is not a DataObject: java.util.Collections$SingletonList"));
}
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#deleteObject(java.lang.Object)}.
* @throws SQLException
*/
@Test
@Ignore("Async cannot be tested")
@ -379,7 +367,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#objectExists(java.lang.String)}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -395,7 +382,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#objectExists(java.lang.String)}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -412,7 +398,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#objectExists(java.lang.String)}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -429,7 +414,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#objectExists(java.lang.String)}.
* @throws SQLException
*/
@Test
@Ignore
@ -447,7 +431,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#objectExists(java.lang.String)}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -461,7 +444,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#deleteID(java.lang.String)}.
* @throws SQLException
*/
@Test
@Ignore("Cannot test async")
@ -475,7 +457,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#deleteID(java.lang.String)}.
* @throws SQLException
*/
@Test
@Ignore("Cannot test async")
@ -501,7 +482,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#MySQLDatabaseHandler(world.bentobox.bentobox.BentoBox, java.lang.Class, world.bentobox.bentobox.database.DatabaseConnector)}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")
@ -512,7 +492,6 @@ public class MySQLDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#MySQLDatabaseHandler(world.bentobox.bentobox.BentoBox, java.lang.Class, world.bentobox.bentobox.database.DatabaseConnector)}.
* @throws SQLException
*/
@Test
@Ignore
@ -523,7 +502,6 @@ public class MySQLDatabaseHandlerTest {
}
/**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#MySQLDatabaseHandler(world.bentobox.bentobox.BentoBox, java.lang.Class, world.bentobox.bentobox.database.DatabaseConnector)}.
* @throws SQLException
*/
@Test
@Ignore("After reworking to HikariCP, this does not work.")

View File

@ -81,7 +81,6 @@ public class YamlDatabaseHandlerTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -122,11 +121,10 @@ public class YamlDatabaseHandlerTest {
config2.save(record2);
// Handler
handler = new YamlDatabaseHandler<Island>(plugin, Island.class, dbConnector);
handler = new YamlDatabaseHandler<>(plugin, Island.class, dbConnector);
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
@ -161,12 +159,6 @@ public class YamlDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.yaml.YamlDatabaseHandler#loadObject(java.lang.String)}.
* @throws IntrospectionException
* @throws NoSuchMethodException
* @throws ClassNotFoundException
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws InstantiationException
*/
@Ignore("YAML database is no longer supported")
@Test
@ -181,9 +173,6 @@ public class YamlDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.yaml.YamlDatabaseHandler#saveObject(java.lang.Object)}.
* @throws IntrospectionException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Ignore("YAML database is no longer supported")
@SuppressWarnings("unchecked")
@ -200,9 +189,6 @@ public class YamlDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.yaml.YamlDatabaseHandler#saveObject(java.lang.Object)}.
* @throws IntrospectionException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Test
public void testSaveObjectNull() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
@ -212,13 +198,10 @@ public class YamlDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.yaml.YamlDatabaseHandler#saveObject(java.lang.Object)}.
* @throws IntrospectionException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Test
public void testSaveObjectNotDO() throws IllegalAccessException, InvocationTargetException, IntrospectionException{
YamlDatabaseHandler<String> h = new YamlDatabaseHandler<String>(plugin, String.class, dbConnector);
YamlDatabaseHandler<String> h = new YamlDatabaseHandler<>(plugin, String.class, dbConnector);
String test = "";
h.saveObject(test);
verify(plugin).logError("This class is not a DataObject: java.lang.String");
@ -226,9 +209,6 @@ public class YamlDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.yaml.YamlDatabaseHandler#deleteObject(java.lang.Object)}.
* @throws IntrospectionException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Test
public void testDeleteObject() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
@ -237,9 +217,6 @@ public class YamlDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.yaml.YamlDatabaseHandler#deleteObject(java.lang.Object)}.
* @throws IntrospectionException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Test
public void testDeleteObjectNull() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
@ -249,13 +226,10 @@ public class YamlDatabaseHandlerTest {
/**
* Test method for {@link world.bentobox.bentobox.database.yaml.YamlDatabaseHandler#deleteObject(java.lang.Object)}.
* @throws IntrospectionException
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Test
public void testDeleteObjectNotDO() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
YamlDatabaseHandler<String> h = new YamlDatabaseHandler<String>(plugin, String.class, dbConnector);
YamlDatabaseHandler<String> h = new YamlDatabaseHandler<>(plugin, String.class, dbConnector);
String test = "";
h.deleteObject(test);
verify(plugin).logError("This class is not a DataObject: java.lang.String");

View File

@ -64,7 +64,6 @@ public class PlaceholderAPIHookTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {

View File

@ -71,7 +71,6 @@ public class BlockEndDragonTest {
private Block block;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -113,7 +112,6 @@ public class BlockEndDragonTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -107,7 +107,6 @@ public class JoinLeaveListenerTest {
private @NonNull Location location;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -183,12 +182,12 @@ public class JoinLeaveListenerTest {
Map<UUID, String> online = new HashMap<>();
Set<Player> onlinePlayers = new HashSet<>();
for (int j = 0; j < NAMES.length; j++) {
for (String name : NAMES) {
Player p1 = mock(Player.class);
UUID u = UUID.randomUUID();
when(p1.getUniqueId()).thenReturn(u);
when(p1.getName()).thenReturn(NAMES[j]);
online.put(u, NAMES[j]);
when(p1.getName()).thenReturn(name);
online.put(u, name);
onlinePlayers.add(p1);
}
onlinePlayers.add(player);
@ -215,7 +214,6 @@ public class JoinLeaveListenerTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() {

View File

@ -77,7 +77,6 @@ public class PanelListenerManagerTest {
private InventoryAction inv;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@ -132,7 +131,6 @@ public class PanelListenerManagerTest {
private final String name;
/**
* @param name
*/
public MyView(String name) {
top = mock(Inventory.class);
@ -142,7 +140,6 @@ public class PanelListenerManagerTest {
}
/**
* @param name
*/
public MyView(String name, Inventory inventory) {
top = inventory;

View File

@ -497,7 +497,6 @@ public class PortalTeleportationListenerTest {
/**
* Test method for {@link PortalTeleportationListener#onIslandPortal(org.bukkit.event.player.PlayerPortalEvent)}.
* @throws Exception
*/
@Test
public void testonIslandPortalFromNetherStandard() throws Exception {

Some files were not shown because too many files have changed in this diff Show More