Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Aug 23, 2020
1 parent 9528824 commit 607c29a
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 69 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Biomes Addon
[![Discord](https://img.shields.io/discord/272499714048524288.svg?logo=discord)](https://discord.bentobox.world)
[![Build Status](https://ci.codemc.org/buildStatus/icon?job=BentoBoxWorld/Biomes)](https://ci.codemc.org/job/BentoBoxWorld/job/Biomes/)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=BentoBoxWorld_Biomes&metric=bugs)](https://sonarcloud.io/dashboard?id=BentoBoxWorld_Biomes)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=BentoBoxWorld_Biomes&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=BentoBoxWorld_Biomes)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=BentoBoxWorld_Biomes&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=BentoBoxWorld_Biomes)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=BentoBoxWorld_Biomes&metric=security_rating)](https://sonarcloud.io/dashboard?id=BentoBoxWorld_Biomes)

Biomes addon for SkyBlock, SkyGrid, CaveBlock and AcidIsland. It allows to change biome on Island.
Biomes addon for SkyBlock, SkyGrid, CaveBlock and AcidIsland. It allows island biome changing.

## Where to find

Currently Biomes Addon is in **Beta stage**, so it may or may not contain bugs... a lot of bugs. Also it means, that some features are not working or implemented.
Latest official **Beta Release is 1.12.0**, and you can download it from [Release tab](https://github.com/BentoBoxWorld/Biomes/releases)

Be aware, the latest version is for Spigot 1.16.0.
Or you can try **nightly builds** where you can check and test new features that will be implemented in next release from [Jenkins Server](https://ci.codemc.org/job/BentoBoxWorld/job/Biomes/lastStableBuild/).
Download the latest release from the BentoBox Downloads site (https://download.bentobox.world) or
you can try **snapshot builds** where you can check and test new features that will be implemented in next release from [Jenkins Server](https://ci.bentobox.world/Biomes/lastStableBuild/).

If you like this addon but something is missing or is not working as you want, you can always submit an [Issue request](https://github.com/BentoBoxWorld/Biomes/issues) or get a support in Discord [BentoBox ![icon](https://avatars2.githubusercontent.com/u/41555324?s=15&v=4)](https://discord.gg/JgWKvR)

Expand All @@ -29,15 +30,16 @@ If your language is not in the list, please contact to developers via Discord an

## Config.yml

After addon is successful installed, it will create config.yml file. Every option in this file comes with comments about them. Please check file for more information.
Most of options are also editable admin via commands.
After the addon is successful installed, it will create a config.yml file. Every option in this file comes with comments.
Please check the file for more information.
Most options are also editable admin via commands.

## Biomes.yml

This file contains all necessary information about default biomes.
If you change values in biomes.yml, then to apply them, you must run **/bsb biomes import** or **/acid biomes import**.

If you want to force an overwrite of biomes via an import, add the **overwrite** option to the end of the import command.
If you want to force an overwrite of the biomes via an import, add the **overwrite** option to the end of the import command.
Note that you must import biomes into both BSkyBlock and AcidIsland separately.

## User commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ public Optional<List<String>> tabComplete(User user, String alias, List<String>
case 3:

// Create suggestions with all biomes that is available for users.
this.addon.getAddonManager().getBiomes(this.getWorld()).forEach(biomesObject -> {
returnList.add(biomesObject.getUniqueId().substring(Utils.getGameMode(this.getWorld()).length() + 1));
});
this.addon.getAddonManager().getBiomes(this.getWorld()).forEach(biomesObject -> returnList.add(biomesObject.getUniqueId().substring(Utils.getGameMode(this.getWorld()).length() + 1)));

break;
case 4:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.bentobox.biomes.commands.admin;


import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

Expand All @@ -17,34 +17,34 @@
*/
public class ImportCommand extends CompositeCommand
{
public ImportCommand(Addon addon, CompositeCommand cmd)
{
super(addon, cmd, "import");
}


@Override
public void setup()
{
this.setPermission("admin.biomes.import");
this.setParametersHelp("biomes.commands.admin.import.parameters");
this.setDescription("biomes.commands.admin.import.description");
}


@Override
public boolean execute(User user, String label, List<String> args)
{
return ((BiomesAddon) this.getAddon()).getAddonManager().importBiomes(user,
this.getWorld(),
!args.isEmpty() && args.get(0).equalsIgnoreCase("overwrite"));
}


@Override
public Optional<List<String>> tabComplete(User user, String alias, List<String> args)
{
String lastArg = !args.isEmpty() ? args.get(args.size() - 1) : "";
return Optional.of(Util.tabLimit(Arrays.asList("overwrite"), lastArg));
}
public ImportCommand(Addon addon, CompositeCommand cmd)
{
super(addon, cmd, "import");
}


@Override
public void setup()
{
this.setPermission("admin.biomes.import");
this.setParametersHelp("biomes.commands.admin.import.parameters");
this.setDescription("biomes.commands.admin.import.description");
}


@Override
public boolean execute(User user, String label, List<String> args)
{
return ((BiomesAddon) this.getAddon()).getAddonManager().importBiomes(user,
this.getWorld(),
!args.isEmpty() && args.get(0).equalsIgnoreCase("overwrite"));
}


@Override
public Optional<List<String>> tabComplete(User user, String alias, List<String> args)
{
String lastArg = !args.isEmpty() ? args.get(args.size() - 1) : "";
return Optional.of(Util.tabLimit(Collections.singletonList("overwrite"), lastArg));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class MigrateCommand extends CompositeCommand {

/**
* Migrates challenges
* @param addon
* @param cmd
* @param addon - addon
* @param cmd - command
*/
public MigrateCommand(Addon addon, CompositeCommand cmd) {
super(addon, cmd, "migrate");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public boolean execute(User user, String label, List<String> args)
{
// Show help if something fails.
this.showHelp(this, user);
return false;
}
}
else
{
// Use BiomeUpdateHelper to change biome for user.
Expand All @@ -81,9 +80,9 @@ public boolean execute(User user, String label, List<String> args)
return true;
}

return false;
}
}
}
return false;
}


@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package world.bentobox.biomes.database.objects;


import java.util.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.bukkit.Material;
import org.bukkit.World;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public BiomeDataRequestHandler(BiomesAddon addon)
/**
* @param metaData Required meta data.
* @return Map that returns information about biome
* @see AddonRequestHandler#handle(Map<String, Object>)
* @see AddonRequestHandler#handle(Map &lt;String, Object&gt;)
*/
@Override
public Object handle(Map<String, Object> metaData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public BiomeListRequestHandler(BiomesAddon addon)
/**
* @param metaData Required meta data.
* @return Set of strings that contains completed challenges.
* @see AddonRequestHandler#handle(Map <String, Object>)
* @see AddonRequestHandler#handle(Map &lt;String, Object&gt;)
*/
@Override
public Object handle(Map<String, Object> metaData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ChangeBiomeRequestHandler(BiomesAddon addon)
/**
* @param metaData Required meta data.
* @return Set of strings that contains completed challenges.
* @see AddonRequestHandler#handle(Map<String, Object>)
* @see AddonRequestHandler#handle(Map&lt;String, Object&gt;)
*/
@Override
public Object handle(Map<String, Object> metaData)
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/world/bentobox/biomes/panels/CommonGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,8 @@ protected List<String> generateBiomesDescription(BiomesObject biomesObject)
result.add(this.user.getTranslation("biomes.gui.biomes-description.required-permissions"));

biomesObject.getRequiredPermissions().forEach(permission ->
{
result.add(this.user.getTranslation("biomes.gui.descriptions.permission",
"[permission]", permission));
});
result.add(this.user.getTranslation("biomes.gui.descriptions.permission",
"[permission]", permission)));
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ private PanelItem getButton(Button button)
name = this.user.getTranslation("biomes.gui.buttons.admin.view");
description = Collections.emptyList();
icon = new ItemStack(Material.YELLOW_STAINED_GLASS_PANE);
clickHandler = (panel, user, clickType, slot) -> {
return true;
};
clickHandler = (panel, user, clickType, slot) -> true;

break;
}
Expand All @@ -214,7 +212,6 @@ private PanelItem getButton(Button button)
private PanelItem getLoreButton(String loreElement)
{
Material icon;
String name = loreElement;
List<String> description = new ArrayList<>();
description.add(this.user.getTranslation(REFERENCE_DESCRIPTION + "lore." + loreElement.toLowerCase()));

Expand Down Expand Up @@ -255,7 +252,7 @@ private PanelItem getLoreButton(String loreElement)
}

return new PanelItemBuilder().
name(name).
name(loreElement).
icon(icon).
description(GuiUtils.stringSplit(description, this.addon.getSettings().getLoreLineLength())).
clickHandler(clickHandler).
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/world/bentobox/biomes/utils/Utils.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package world.bentobox.biomes.utils;


import java.util.HashMap;
import java.util.Map;

import org.bukkit.World;
import org.bukkit.block.Biome;

import java.util.*;

import world.bentobox.bentobox.BentoBox;


Expand Down Expand Up @@ -47,7 +48,7 @@ public static int normalizeBy4(int coordinate)
* @param <T> Instance of given object.
* @return Next value after currentValue in values array.
*/
public static <T extends Object> T getNextValue(T[] values, T currentValue)
public static <T> T getNextValue(T[] values, T currentValue)
{
for (int i = 0; i < values.length; i++)
{
Expand Down Expand Up @@ -75,7 +76,7 @@ public static <T extends Object> T getNextValue(T[] values, T currentValue)
* @param <T> Instance of given object.
* @return Previous value before currentValue in values array.
*/
public static <T extends Object> T getPreviousValue(T[] values, T currentValue)
public static <T> T getPreviousValue(T[] values, T currentValue)
{
for (int i = 0; i < values.length; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public class AddBiomeCommandTest {

@Mock
private CompositeCommand ic;
private UUID uuid;
@Mock
private User user;
@Mock
Expand Down Expand Up @@ -136,7 +135,7 @@ public void setUp() throws Exception {
PowerMockito.mockStatic(User.class);
// Sometimes use Mockito.withSettings().verboseLogging()
when(user.isOp()).thenReturn(false);
uuid = UUID.randomUUID();
UUID uuid = UUID.randomUUID();
when(user.getUniqueId()).thenReturn(uuid);
when(user.getPlayer()).thenReturn(p);
when(user.getName()).thenReturn("tastybento");
Expand Down

0 comments on commit 607c29a

Please sign in to comment.