into develop
This commit is contained in:
tastybento 2023-02-25 11:29:48 -08:00
commit a95f0b790e
16 changed files with 846 additions and 535 deletions

View File

@ -408,16 +408,21 @@
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>

View File

@ -170,20 +170,14 @@ public class Level extends Addon {
{
this.visitHook = (VisitAddon) addon;
this.log("Level Addon hooked into Visit addon.");
}, () ->
{
this.visitHook = null;
});
}, () -> this.visitHook = null);
// Try to find Warps addon and if it does not exist, display a warning
this.getAddonByName("Warps").ifPresentOrElse(addon ->
{
this.warpHook = (Warp) addon;
this.log("Level Addon hooked into Warps addon.");
}, () ->
{
this.warpHook = null;
});
}, () -> this.warpHook = null);
}
@ -212,9 +206,6 @@ public class Level extends Addon {
return comparisonResult;
}
private void registerCommands(GameModeAddon gm) {
gm.getAdminCommand().ifPresent(adminCommand -> {
new AdminLevelCommand(this, adminCommand);
@ -351,7 +342,7 @@ public class Level extends Addon {
* @param playerUUID - the target island member's UUID
* @deprecated Do not use this anymore. Use getManager().calculateLevel(playerUUID, island)
*/
@Deprecated
@Deprecated(since="2.3.0", forRemoval=true)
public void calculateIslandLevel(World world, @Nullable User user, @NonNull UUID playerUUID) {
Island island = getIslands().getIsland(world, playerUUID);
if (island != null) getManager().calculateLevel(playerUUID, island);
@ -363,7 +354,7 @@ public class Level extends Addon {
* @return LevelsData object or null if not found. Only island levels are set!
* @deprecated Do not use this anymore. Use {@link #getIslandLevel(World, UUID)}
*/
@Deprecated
@Deprecated(since="2.3.0", forRemoval=true)
public LevelsData getLevelsData(UUID targetPlayer) {
LevelsData ld = new LevelsData(targetPlayer);
getPlugin().getAddonsManager().getGameModeAddons().stream()

View File

@ -152,8 +152,6 @@ public class LevelsManager {
addon.getPipeliner().addIsland(island).thenAccept(r -> {
// Results are irrelevant because the island is unowned or deleted, or IslandLevelCalcEvent is cancelled
if (r == null || fireIslandLevelCalcEvent(targetPlayer, island, r)) {
System.out.println("results are null or event canceled");
result.complete(null);
}
// Save result
@ -337,7 +335,7 @@ public class LevelsManager {
.filter(e -> addon.getIslands().isOwner(world, e.getKey()))
.filter(l -> l.getValue() > 0)
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()));
return stream.takeWhile(x -> !x.getKey().equals(uuid)).map(Map.Entry::getKey).collect(Collectors.toList()).size() + 1;
return (int) (stream.takeWhile(x -> !x.getKey().equals(uuid)).map(Map.Entry::getKey).count() + 1);
}
/**
@ -363,10 +361,7 @@ public class LevelsManager {
addon.getIslands().getIslandById(il.getUniqueId()).ifPresent(i -> this.addToTopTen(i, il.getLevel()));
}
});
topTenLists.keySet().forEach(w -> {
addon.log("Generated rankings for " + w.getName());
});
topTenLists.keySet().forEach(w -> addon.log("Generated rankings for " + w.getName()));
});
}

View File

@ -1,11 +1,11 @@
package world.bentobox.level.calculators;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -24,13 +24,11 @@ import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Container;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.block.*;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Slab;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.scheduler.BukkitTask;
import com.bgsoftware.wildstacker.api.WildStackerAPI;
@ -67,9 +65,10 @@ public class IslandLevelCalculator {
* @param str - equation to evaluate
* @return value of equation
*/
private static double eval(final String str) {
private static double eval(final String str) throws IOException {
return new Object() {
int pos = -1, ch;
int pos = -1;
int ch;
boolean eat(int charToEat) {
while (ch == ' ') nextChar();
@ -84,10 +83,10 @@ public class IslandLevelCalculator {
ch = (++pos < str.length()) ? str.charAt(pos) : -1;
}
double parse() {
double parse() throws IOException {
nextChar();
double x = parseExpression();
if (pos < str.length()) throw new RuntimeException("Unexpected: " + (char)ch);
if (pos < str.length()) throw new IOException("Unexpected: " + (char)ch);
return x;
}
@ -97,7 +96,7 @@ public class IslandLevelCalculator {
// factor = `+` factor | `-` factor | `(` expression `)`
// | number | functionName factor | factor `^` factor
double parseExpression() {
double parseExpression() throws IOException {
double x = parseTerm();
for (;;) {
if (eat('+')) x += parseTerm(); // addition
@ -106,7 +105,7 @@ public class IslandLevelCalculator {
}
}
double parseFactor() {
double parseFactor() throws IOException {
if (eat('+')) return parseFactor(); // unary plus
if (eat('-')) return -parseFactor(); // unary minus
@ -139,10 +138,10 @@ public class IslandLevelCalculator {
x = Math.log(x);
break;
default:
throw new RuntimeException("Unknown function: " + func);
throw new IOException("Unknown function: " + func);
}
} else {
throw new RuntimeException("Unexpected: " + (char)ch);
throw new IOException("Unexpected: " + (char)ch);
}
if (eat('^')) x = Math.pow(x, parseFactor()); // exponentiation
@ -150,7 +149,7 @@ public class IslandLevelCalculator {
return x;
}
double parseTerm() {
double parseTerm() throws IOException {
double x = parseFactor();
for (;;) {
if (eat('*')) x *= parseFactor(); // multiplication
@ -163,7 +162,7 @@ public class IslandLevelCalculator {
private final Level addon;
private final Queue<Pair<Integer, Integer>> chunksToCheck;
private final Island island;
private final HashMap<Material, Integer> limitCount;
private final Map<Material, Integer> limitCount;
private final CompletableFuture<Results> r;
@ -192,7 +191,7 @@ public class IslandLevelCalculator {
results = new Results();
duration = System.currentTimeMillis();
chunksToCheck = getChunksToScan(island);
this.limitCount = new HashMap<>(addon.getBlockConfig().getBlockLimits());
this.limitCount = new EnumMap<>(addon.getBlockConfig().getBlockLimits());
// Get the initial island level
results.initialLevel.set(addon.getInitialIslandLevel(island));
// Set up the worlds
@ -223,7 +222,15 @@ public class IslandLevelCalculator {
private long calculateLevel(long blockAndDeathPoints) {
String calcString = addon.getSettings().getLevelCalc();
String withValues = calcString.replace("blocks", String.valueOf(blockAndDeathPoints)).replace("level_cost", String.valueOf(this.addon.getSettings().getLevelCost()));
return (long)eval(withValues) - (addon.getSettings().isZeroNewIslandLevels() ? results.initialLevel.get() : 0);
long evalWithValues;
try {
evalWithValues = (long)eval(withValues);
return evalWithValues - (addon.getSettings().isZeroNewIslandLevels() ? results.initialLevel.get() : 0);
} catch (IOException e) {
addon.getPlugin().logStacktrace(e);
return 0L;
}
}
/**
@ -426,7 +433,7 @@ public class IslandLevelCalculator {
private void scanChests(Chunk chunk) {
// Count blocks in chests
for (BlockState bs : chunk.getTileEntities()) {
if (bs instanceof Container) {
if (bs instanceof Container container) {
if (addon.isAdvChestEnabled()) {
AdvancedChest<?,?> aChest = AdvancedChestsAPI.getChestManager().getAdvancedChest(bs.getLocation());
if (aChest != null && aChest.getChestType().getName().equals("NORMAL")) {
@ -439,16 +446,22 @@ public class IslandLevelCalculator {
}
}
// Regular chest
((Container)bs).getSnapshotInventory().forEach(this::countItemStack);
container.getSnapshotInventory().forEach(this::countItemStack);
}
}
}
private void countItemStack(ItemStack i) {
if (i != null && i.getType().isBlock()) {
if (i == null || !i.getType().isBlock()) return;
for (int c = 0; c < i.getAmount(); c++) {
checkBlock(i.getType(), false);
if (addon.getSettings().isIncludeShulkersInChest()
&& i.getItemMeta() instanceof BlockStateMeta blockStateMeta
&& blockStateMeta.getBlockState() instanceof ShulkerBox shulkerBox) {
shulkerBox.getSnapshotInventory().forEach(this::countItemStack);
}
checkBlock(i.getType(), false);
}
}
@ -509,7 +522,7 @@ public class IslandLevelCalculator {
}
// Hook for Wild Stackers (Blocks and Spawners Only) - this has to use the real chunk
if (addon.isStackersEnabled() && (blockData.getMaterial().equals(Material.CAULDRON) || blockData.getMaterial().equals(Material.SPAWNER))) {
stackedBlocks.add(new Location(cp.world, x + cp.chunkSnapshot.getX() * 16,y,z + cp.chunkSnapshot.getZ() * 16));
stackedBlocks.add(new Location(cp.world, (double)x + cp.chunkSnapshot.getX() * 16, y, (double)z + cp.chunkSnapshot.getZ() * 16));
}
// Scan chests
if (addon.getSettings().isIncludeChests() && CHESTS.contains(blockData.getMaterial())) {
@ -560,21 +573,21 @@ public class IslandLevelCalculator {
}
private Collection<String> sortedReport(int total, Multiset<Material> materialCount) {
Collection<String> r = new ArrayList<>();
Collection<String> result = new ArrayList<>();
Iterable<Multiset.Entry<Material>> entriesSortedByCount = Multisets.copyHighestCountFirst(materialCount).entrySet();
for (Entry<Material> en : entriesSortedByCount) {
Material type = en.getElement();
int value = getValue(type);
r.add(type.toString() + ":"
result.add(type.toString() + ":"
+ String.format("%,d", en.getCount()) + " blocks x " + value + " = " + (value * en.getCount()));
total += (value * en.getCount());
}
r.add("Subtotal = " + total);
r.add(LINE_BREAK);
return r;
result.add("Subtotal = " + total);
result.add(LINE_BREAK);
return result;
}
@ -634,7 +647,7 @@ public class IslandLevelCalculator {
public void scanIsland(Pipeliner pipeliner) {
// Scan the next chunk
scanNextChunk().thenAccept(r -> {
scanNextChunk().thenAccept(result -> {
if (!Bukkit.isPrimaryThread()) {
addon.getPlugin().logError("scanChunk not on Primary Thread!");
}
@ -649,7 +662,7 @@ public class IslandLevelCalculator {
}
return;
}
if (Boolean.TRUE.equals(r) && !pipeliner.getTask().isCancelled()) {
if (Boolean.TRUE.equals(result) && !pipeliner.getTask().isCancelled()) {
// scanNextChunk returns true if there are more chunks to scan
scanIsland(pipeliner);
} else {

View File

@ -2,7 +2,6 @@ package world.bentobox.level.commands;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
@ -60,6 +59,6 @@ public class AdminTopRemoveCommand extends CompositeCommand {
@Override
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
return Optional.of(addon.getManager().getTopTen(getWorld(), Level.TEN).keySet().stream().map(addon.getPlayers()::getName)
.filter(n -> !n.isEmpty()).collect(Collectors.toList()));
.filter(n -> !n.isEmpty()).toList());
}
}

View File

@ -19,6 +19,7 @@ import world.bentobox.level.util.Utils;
public class IslandValueCommand extends CompositeCommand
{
private static final String MATERIAL = "[material]";
private final Level addon;
@ -45,7 +46,7 @@ public class IslandValueCommand extends CompositeCommand
if (args.size() > 1)
{
this.showHelp(this, user);
return true;
return false;
}
if (args.isEmpty())
@ -74,7 +75,7 @@ public class IslandValueCommand extends CompositeCommand
{
Utils.sendMessage(user,
user.getTranslation(this.getWorld(), "level.conversations.unknown-item",
"[material]", args.get(0)));
MATERIAL, args.get(0)));
}
else
{
@ -100,7 +101,7 @@ public class IslandValueCommand extends CompositeCommand
Utils.sendMessage(user,
user.getTranslation(this.getWorld(), "level.conversations.value",
"[value]", String.valueOf(value),
"[material]", Utils.prettifyObject(material, user)));
MATERIAL, Utils.prettifyObject(material, user)));
double underWater = this.addon.getSettings().getUnderWaterMultiplier();
@ -109,7 +110,7 @@ public class IslandValueCommand extends CompositeCommand
Utils.sendMessage(user,
user.getTranslation(this.getWorld(),"level.conversations.success-underwater",
"[value]", (underWater * value) + ""),
"[material]", Utils.prettifyObject(material, user));
MATERIAL, Utils.prettifyObject(material, user));
}
}
else

View File

@ -119,6 +119,12 @@ public class ConfigSettings implements ConfigObject {
@ConfigComment("Shows large level values rounded down, e.g., 10,345 -> 10k")
@ConfigEntry(path = "shorthand")
private boolean shorthand = false;
@ConfigComment("")
@ConfigComment("Include Shulker Box content in chests in level calculations.")
@ConfigComment("Will count blocks in Shulker Boxes inside of chests.")
@ConfigComment("NOTE: include-chests needs to be enabled for this to work!.")
@ConfigEntry(path = "include-shulkers-in-chest")
private boolean includeShulkersInChest = false;
/**
@ -385,4 +391,17 @@ public class ConfigSettings implements ConfigObject {
this.logReportToConsole = logReportToConsole;
}
/**
* @return includeShulkersInChest
*/
public boolean isIncludeShulkersInChest() {
return includeShulkersInChest;
}
/**
* @param includeShulkersInChest the includeChests to set
*/
public void setIncludeShulkersInChest(boolean includeShulkersInChest) {
this.includeShulkersInChest = includeShulkersInChest;
}
}

View File

@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
import com.google.common.base.Enums;
import lv.id.bonne.panelutils.PanelUtils;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.TemplatedPanel;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
@ -132,25 +133,19 @@ public class DetailsPanel
materialCountMap.putAll(this.levelsData.getMdCount());
// Add underwater blocks.
this.levelsData.getUwCount().forEach((material, count) -> {
materialCountMap.put(material,
materialCountMap.computeIfAbsent(material, key -> 0) + count);
});
this.levelsData.getUwCount().forEach((material, count) -> materialCountMap.put(material,
materialCountMap.computeIfAbsent(material, key -> 0) + count));
materialCountMap.entrySet().stream().sorted((Map.Entry.comparingByKey())).
forEachOrdered(entry ->
this.materialCountList.add(new Pair<>(entry.getKey(), entry.getValue())));
}
case ABOVE_SEA_LEVEL -> {
this.levelsData.getMdCount().entrySet().stream().sorted((Map.Entry.comparingByKey())).
forEachOrdered(entry ->
this.materialCountList.add(new Pair<>(entry.getKey(), entry.getValue())));
}
case UNDERWATER -> {
this.levelsData.getUwCount().entrySet().stream().sorted((Map.Entry.comparingByKey())).
forEachOrdered(entry ->
this.materialCountList.add(new Pair<>(entry.getKey(), entry.getValue())));
}
case ABOVE_SEA_LEVEL -> this.levelsData.getMdCount().entrySet().stream().sorted((Map.Entry.comparingByKey()))
.forEachOrdered(entry -> this.materialCountList.add(new Pair<>(entry.getKey(), entry.getValue())));
case UNDERWATER -> this.levelsData.getUwCount().entrySet().stream().sorted((Map.Entry.comparingByKey()))
.forEachOrdered(entry -> this.materialCountList.add(new Pair<>(entry.getKey(), entry.getValue())));
case SPAWNER -> {
int aboveWater = this.levelsData.getMdCount().getOrDefault(Material.SPAWNER, 0);
int underWater = this.levelsData.getUwCount().getOrDefault(Material.SPAWNER, 0);
@ -274,9 +269,8 @@ public class DetailsPanel
{
for (ItemTemplateRecord.ActionRecords action : activeActions)
{
if (clickType == action.clickType() || ClickType.UNKNOWN.equals(action.clickType()))
{
if ("VIEW".equalsIgnoreCase(action.actionType()))
if ((clickType == action.clickType() || ClickType.UNKNOWN.equals(action.clickType()))
&& "VIEW".equalsIgnoreCase(action.actionType()))
{
this.activeTab = tab;
@ -285,7 +279,6 @@ public class DetailsPanel
this.build();
}
}
}
return true;
});
@ -453,7 +446,7 @@ public class DetailsPanel
{
ItemStack clone = template.icon().clone();
if ((Boolean) template.dataMap().getOrDefault("indexing", false))
if (Boolean.TRUE.equals(template.dataMap().getOrDefault("indexing", false)))
{
clone.setAmount(nextPageIndex);
}
@ -469,7 +462,7 @@ public class DetailsPanel
if (template.description() != null)
{
builder.description(this.user.getTranslation(this.world, template.description(),
"[number]", String.valueOf(nextPageIndex)));
TextVariables.NUMBER, String.valueOf(nextPageIndex)));
}
// Add ClickHandler
@ -477,15 +470,13 @@ public class DetailsPanel
{
for (ItemTemplateRecord.ActionRecords action : template.actions())
{
if (clickType == action.clickType() || ClickType.UNKNOWN.equals(action.clickType()))
{
if ("NEXT".equalsIgnoreCase(action.actionType()))
if ((clickType == action.clickType() || ClickType.UNKNOWN.equals(action.clickType())) &&
"NEXT".equalsIgnoreCase(action.actionType()))
{
this.pageIndex++;
this.build();
}
}
}
// Always return true.
return true;
@ -533,7 +524,7 @@ public class DetailsPanel
{
ItemStack clone = template.icon().clone();
if ((Boolean) template.dataMap().getOrDefault("indexing", false))
if (Boolean.TRUE.equals(template.dataMap().getOrDefault("indexing", false)))
{
clone.setAmount(previousPageIndex);
}
@ -549,7 +540,7 @@ public class DetailsPanel
if (template.description() != null)
{
builder.description(this.user.getTranslation(this.world, template.description(),
"[number]", String.valueOf(previousPageIndex)));
TextVariables.NUMBER, String.valueOf(previousPageIndex)));
}
// Add ClickHandler
@ -557,15 +548,13 @@ public class DetailsPanel
{
for (ItemTemplateRecord.ActionRecords action : template.actions())
{
if (clickType == action.clickType() || ClickType.UNKNOWN.equals(action.clickType()))
{
if ("PREVIOUS".equalsIgnoreCase(action.actionType()))
if ((clickType == action.clickType() || ClickType.UNKNOWN.equals(action.clickType()))
&& "PREVIOUS".equalsIgnoreCase(action.actionType()))
{
this.pageIndex--;
this.build();
}
}
}
// Always return true.
return true;
@ -651,7 +640,7 @@ public class DetailsPanel
if (template.title() != null)
{
builder.name(this.user.getTranslation(this.world, template.title(),
"[number]", String.valueOf(materialCount.getValue()),
TextVariables.NUMBER, String.valueOf(materialCount.getValue()),
"[material]", Utils.prettifyObject(materialCount.getKey(), this.user)));
}
@ -663,18 +652,18 @@ public class DetailsPanel
int blockValue = this.addon.getBlockConfig().getBlockValues().getOrDefault(materialCount.getKey(), 0);
String value = blockValue > 0 ? this.user.getTranslationOrNothing(reference + "value",
"[number]", String.valueOf(blockValue)) : "";
TextVariables.NUMBER, String.valueOf(blockValue)) : "";
int blockLimit = this.addon.getBlockConfig().getBlockLimits().getOrDefault(materialCount.getKey(), 0);
String limit = blockLimit > 0 ? this.user.getTranslationOrNothing(reference + "limit",
"[number]", String.valueOf(blockLimit)) : "";
TextVariables.NUMBER, String.valueOf(blockLimit)) : "";
String count = this.user.getTranslationOrNothing(reference + "count",
"[number]", String.valueOf(materialCount.getValue()));
TextVariables.NUMBER, String.valueOf(materialCount.getValue()));
long calculatedValue = (long) Math.min(blockLimit > 0 ? blockLimit : Integer.MAX_VALUE, materialCount.getValue()) * blockValue;
String valueText = calculatedValue > 0 ? this.user.getTranslationOrNothing(reference + "calculated",
"[number]", String.valueOf(calculatedValue)) : "";
TextVariables.NUMBER, String.valueOf(calculatedValue)) : "";
if (template.description() != null)
{
@ -687,7 +676,7 @@ public class DetailsPanel
"[count]", count).
replaceAll("(?m)^[ \\t]*\\r?\\n", "").
replaceAll("(?<!\\\\)\\|", "\n").
replaceAll("\\\\\\|", "|"));
replace("\\\\\\|", "|"));
}
return builder.build();

View File

@ -6,14 +6,18 @@
package world.bentobox.level.panels;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.event.inventory.ClickType;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.TemplatedPanel;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
@ -31,6 +35,8 @@ import world.bentobox.level.util.Utils;
*/
public class TopLevelPanel
{
// ---------------------------------------------------------------------
// Section: Internal Constructor
// ---------------------------------------------------------------------
@ -100,8 +106,6 @@ public class TopLevelPanel
return null;
}
final String reference = "level.gui.buttons.island.";
PanelItemBuilder builder = new PanelItemBuilder();
if (template.icon() != null)
@ -112,18 +116,18 @@ public class TopLevelPanel
if (template.title() != null)
{
builder.name(this.user.getTranslation(this.world, template.title(),
"[name]", String.valueOf(index)));
TextVariables.NAME, String.valueOf(index)));
}
else
{
builder.name(this.user.getTranslation(this.world, reference,
"[name]", String.valueOf(index)));
builder.name(this.user.getTranslation(this.world, REFERENCE,
TextVariables.NAME, String.valueOf(index)));
}
if (template.description() != null)
{
builder.description(this.user.getTranslation(this.world, template.description(),
"[number]", String.valueOf(index)));
TextVariables.NUMBER, String.valueOf(index)));
}
builder.amount(index != 0 ? (int) index : 1);
@ -222,7 +226,7 @@ public class TopLevelPanel
this.user.closeInventory();
this.addon.getWarpHook().getWarpSignsManager().warpPlayer(this.world, this.user, island.getOwner());
}
case "VISIT" -> {
case "VISIT" ->
// The command call implementation solves necessity to check for all visits options,
// like cool down, confirmation and preprocess in single go. Would it be better to write
// all logic here?
@ -239,12 +243,17 @@ public class TopLevelPanel
this.user.performCommand(command.getTopLabel() + " " + mainCommand + " " + island.getOwner());
}
});
}
case "VIEW" -> {
this.user.closeInventory();
// Open Detailed GUI.
DetailsPanel.openPanel(this.addon, this.world, this.user);
}
// Catch default
default -> {
this.user.closeInventory();
addon.logError("Unknown action type " + action.actionType().toUpperCase());
}
}
}
}
@ -282,17 +291,16 @@ public class TopLevelPanel
ItemTemplateRecord template,
Island island)
{
final String reference = "level.gui.buttons.island.";
// Get Island Name
String nameText;
if (island.getName() == null || island.getName().isEmpty())
{
nameText = this.user.getTranslation(reference + "owners-island",
"[player]",
nameText = this.user.getTranslation(REFERENCE + "owners-island",
PLAYER,
island.getOwner() == null ?
this.user.getTranslation(reference + "unknown") :
this.user.getTranslation(REFERENCE + "unknown") :
this.addon.getPlayers().getName(island.getOwner()));
}
else
@ -304,11 +312,11 @@ public class TopLevelPanel
if (template.title() != null && !template.title().isBlank())
{
builder.name(this.user.getTranslation(this.world, template.title(),
"[name]", nameText));
TextVariables.NAME, nameText));
}
else
{
builder.name(this.user.getTranslation(reference + "name", "[name]", nameText));
builder.name(this.user.getTranslation(REFERENCE + "name", TextVariables.NAME, nameText));
}
}
@ -382,13 +390,11 @@ public class TopLevelPanel
IslandTopRecord islandTopRecord,
int index)
{
final String reference = "level.gui.buttons.island.";
// Get Owner Name
String ownerText = this.user.getTranslation(reference + "owner",
"[player]",
String ownerText = this.user.getTranslation(REFERENCE + "owner",
PLAYER,
island.getOwner() == null ?
this.user.getTranslation(reference + "unknown") :
this.user.getTranslation(REFERENCE + "unknown") :
this.addon.getPlayers().getName(island.getOwner()));
// Get Members Text
@ -397,11 +403,11 @@ public class TopLevelPanel
if (island.getMemberSet().size() > 1)
{
StringBuilder memberBuilder = new StringBuilder(
this.user.getTranslationOrNothing(reference + "members-title"));
this.user.getTranslationOrNothing(REFERENCE + "members-title"));
for (UUID uuid : island.getMemberSet())
{
User user = User.getInstance(uuid);
User member = User.getInstance(uuid);
if (memberBuilder.length() > 0)
{
@ -409,8 +415,8 @@ public class TopLevelPanel
}
memberBuilder.append(
this.user.getTranslationOrNothing(reference + "member",
"[player]", user.getName()));
this.user.getTranslationOrNothing(REFERENCE + "member",
PLAYER, member.getName()));
}
memberText = memberBuilder.toString();
@ -420,11 +426,11 @@ public class TopLevelPanel
memberText = "";
}
String placeText = this.user.getTranslation(reference + "place",
"[number]", String.valueOf(index));
String placeText = this.user.getTranslation(REFERENCE + "place",
TextVariables.NUMBER, String.valueOf(index));
String levelText = this.user.getTranslation(reference + "level",
"[number]", this.addon.getManager().formatLevel(islandTopRecord.level()));
String levelText = this.user.getTranslation(REFERENCE + "level",
TextVariables.NUMBER, this.addon.getManager().formatLevel(islandTopRecord.level()));
// Template specific description is always more important than custom one.
if (template.description() != null && !template.description().isBlank())
@ -436,12 +442,12 @@ public class TopLevelPanel
"[place]", placeText).
replaceAll("(?m)^[ \\t]*\\r?\\n", "").
replaceAll("(?<!\\\\)\\|", "\n").
replaceAll("\\\\\\|", "|"));
replace("\\\\\\|", "|")); // Not a regex - replace is more efficient
}
else
{
// Now combine everything.
String descriptionText = this.user.getTranslation(reference + "description",
String descriptionText = this.user.getTranslation(REFERENCE + "description",
"[owner]", ownerText,
"[members]", memberText,
"[level]", levelText,
@ -450,7 +456,7 @@ public class TopLevelPanel
builder.description(descriptionText.
replaceAll("(?m)^[ \\t]*\\r?\\n", "").
replaceAll("(?<!\\\\)\\|", "\n").
replaceAll("\\\\\\|", "|"));
replace("\\\\\\|", "|")); // Not a regex - replace is more efficient
}
}
@ -473,9 +479,9 @@ public class TopLevelPanel
int place = this.addon.getManager().getRank(this.world, this.user.getUniqueId());
long level = this.addon.getIslandLevel(this.world, island.getOwner());
IslandTopRecord record = new IslandTopRecord(island, level);
IslandTopRecord topRecord = new IslandTopRecord(island, level);
return this.createIslandIcon(template, record, place);
return this.createIslandIcon(template, topRecord, place);
}
@ -493,12 +499,17 @@ public class TopLevelPanel
new TopLevelPanel(addon, user, world, permissionPrefix).build();
}
// ---------------------------------------------------------------------
// Section: Constants
// ---------------------------------------------------------------------
private static final String REFERENCE = "level.gui.buttons.island.";
private static final String PLAYER = "[player]";
// ---------------------------------------------------------------------
// Section: Record
// ---------------------------------------------------------------------
/**
* This record is used internally. It converts user -> level to island -> level.
*/

View File

@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
import com.google.common.base.Enums;
import lv.id.bonne.panelutils.PanelUtils;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.TemplatedPanel;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
@ -33,6 +34,7 @@ import world.bentobox.level.util.Utils;
*/
public class ValuePanel
{
// ---------------------------------------------------------------------
// Section: Internal Constructor
// ---------------------------------------------------------------------
@ -89,7 +91,7 @@ public class ValuePanel
panelBuilder.registerTypeBuilder("NEXT", this::createNextButton);
panelBuilder.registerTypeBuilder("PREVIOUS", this::createPreviousButton);
panelBuilder.registerTypeBuilder("BLOCK", this::createMaterialButton);
panelBuilder.registerTypeBuilder(BLOCK, this::createMaterialButton);
panelBuilder.registerTypeBuilder("FILTER", this::createFilterButton);
panelBuilder.registerTypeBuilder("SEARCH", this::createSearchButton);
@ -109,7 +111,7 @@ public class ValuePanel
switch (this.activeFilter)
{
case VALUE_ASC ->
{
sorter = (o1, o2) ->
{
if (o1.value().equals(o2.value()))
@ -124,9 +126,9 @@ public class ValuePanel
return Integer.compare(o1.value(), o2.value());
}
};
}
case VALUE_DESC ->
{
sorter = (o1, o2) ->
{
if (o1.value().equals(o2.value()))
@ -141,9 +143,9 @@ public class ValuePanel
return Integer.compare(o2.value(), o1.value());
}
};
}
case NAME_DESC ->
{
sorter = (o1, o2) ->
{
String o1Name = Utils.prettifyObject(o1.material(), this.user);
@ -151,9 +153,9 @@ public class ValuePanel
return String.CASE_INSENSITIVE_ORDER.compare(o2Name, o1Name);
};
}
default ->
{
sorter = (o1, o2) ->
{
String o1Name = Utils.prettifyObject(o1.material(), this.user);
@ -161,7 +163,7 @@ public class ValuePanel
return String.CASE_INSENSITIVE_ORDER.compare(o1Name, o2Name);
};
}
}
this.materialRecordList.sort(sorter);
@ -171,12 +173,12 @@ public class ValuePanel
this.elementList = new ArrayList<>(this.materialRecordList.size());
final String text = this.searchText.toLowerCase();
this.materialRecordList.forEach(record ->
this.materialRecordList.forEach(rec ->
{
if (record.material.name().toLowerCase().contains(text) ||
Utils.prettifyObject(record.material(), this.user).toLowerCase().contains(text))
if (rec.material.name().toLowerCase().contains(text) ||
Utils.prettifyObject(rec.material(), this.user).toLowerCase().contains(text))
{
this.elementList.add(record);
this.elementList.add(rec);
}
});
}
@ -413,8 +415,8 @@ public class ValuePanel
{
long size = this.elementList.size();
if (size <= slot.amountMap().getOrDefault("BLOCK", 1) ||
1.0 * size / slot.amountMap().getOrDefault("BLOCK", 1) <= this.pageIndex + 1)
if (size <= slot.amountMap().getOrDefault(BLOCK, 1) ||
1.0 * size / slot.amountMap().getOrDefault(BLOCK, 1) <= this.pageIndex + 1)
{
// There are no next elements
return null;
@ -428,7 +430,7 @@ public class ValuePanel
{
ItemStack clone = template.icon().clone();
if ((Boolean) template.dataMap().getOrDefault("indexing", false))
if (Boolean.TRUE.equals(template.dataMap().getOrDefault("indexing", false)))
{
clone.setAmount(nextPageIndex);
}
@ -444,7 +446,7 @@ public class ValuePanel
if (template.description() != null)
{
builder.description(this.user.getTranslation(this.world, template.description(),
"[number]", String.valueOf(nextPageIndex)));
TextVariables.NUMBER, String.valueOf(nextPageIndex)));
}
// Add ClickHandler
@ -452,15 +454,13 @@ public class ValuePanel
{
for (ItemTemplateRecord.ActionRecords action : template.actions())
{
if (clickType == action.clickType() || ClickType.UNKNOWN.equals(action.clickType()))
{
if ("NEXT".equalsIgnoreCase(action.actionType()))
if ((clickType == action.clickType() || ClickType.UNKNOWN.equals(action.clickType()))
&& "NEXT".equalsIgnoreCase(action.actionType()))
{
this.pageIndex++;
this.build();
}
}
}
// Always return true.
return true;
@ -508,7 +508,7 @@ public class ValuePanel
{
ItemStack clone = template.icon().clone();
if ((Boolean) template.dataMap().getOrDefault("indexing", false))
if (Boolean.TRUE.equals(template.dataMap().getOrDefault("indexing", false)))
{
clone.setAmount(previousPageIndex);
}
@ -524,7 +524,7 @@ public class ValuePanel
if (template.description() != null)
{
builder.description(this.user.getTranslation(this.world, template.description(),
"[number]", String.valueOf(previousPageIndex)));
TextVariables.NUMBER, String.valueOf(previousPageIndex)));
}
// Add ClickHandler
@ -532,15 +532,13 @@ public class ValuePanel
{
for (ItemTemplateRecord.ActionRecords action : template.actions())
{
if (clickType == action.clickType() || ClickType.UNKNOWN.equals(action.clickType()))
{
if ("PREVIOUS".equalsIgnoreCase(action.actionType()))
if ((clickType == action.clickType() || ClickType.UNKNOWN.equals(action.clickType()))
&& "PREVIOUS".equalsIgnoreCase(action.actionType()))
{
this.pageIndex--;
this.build();
}
}
}
// Always return true.
return true;
@ -585,7 +583,7 @@ public class ValuePanel
return null;
}
int index = this.pageIndex * slot.amountMap().getOrDefault("BLOCK", 1) + slot.slot();
int index = this.pageIndex * slot.amountMap().getOrDefault(BLOCK, 1) + slot.slot();
if (index >= this.elementList.size())
{
@ -636,14 +634,14 @@ public class ValuePanel
"[id]", materialRecord.material().name());
String value = this.user.getTranslationOrNothing(reference + "value",
"[number]", String.valueOf(materialRecord.value()));
TextVariables.NUMBER, String.valueOf(materialRecord.value()));
String underWater;
if (this.addon.getSettings().getUnderWaterMultiplier() > 1.0)
{
underWater = this.user.getTranslationOrNothing(reference + "underwater",
"[number]", String.valueOf(materialRecord.value() * this.addon.getSettings().getUnderWaterMultiplier()));
TextVariables.NUMBER, String.valueOf(materialRecord.value() * this.addon.getSettings().getUnderWaterMultiplier()));
}
else
{
@ -651,7 +649,7 @@ public class ValuePanel
}
String limit = materialRecord.limit() > 0 ? this.user.getTranslationOrNothing(reference + "limit",
"[number]", String.valueOf(materialRecord.limit())) : "";
TextVariables.NUMBER, String.valueOf(materialRecord.limit())) : "";
if (template.description() != null)
{
@ -663,11 +661,11 @@ public class ValuePanel
"[limit]", limit).
replaceAll("(?m)^[ \\t]*\\r?\\n", "").
replaceAll("(?<!\\\\)\\|", "\n").
replaceAll("\\\\\\|", "|"));
replace("\\\\\\|", "|")); // Non regex
}
builder.clickHandler((panel, user1, clickType, i) -> {
System.out.println("Material: " + materialRecord.material());
addon.log("Material: " + materialRecord.material());
return true;
});
@ -729,6 +727,11 @@ public class ValuePanel
{
}
// ---------------------------------------------------------------------
// Section: Constants
// ---------------------------------------------------------------------
private static final String BLOCK = "BLOCK";
// ---------------------------------------------------------------------
// Section: Variables

View File

@ -7,10 +7,16 @@
package world.bentobox.level.util;
import org.bukkit.conversations.*;
import java.util.function.Consumer;
import org.bukkit.conversations.ConversationAbandonedListener;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.ConversationFactory;
import org.bukkit.conversations.MessagePrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import java.util.function.Consumer;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.user.User;
@ -22,6 +28,7 @@ public class ConversationUtils
// Section: Conversation API implementation
// ---------------------------------------------------------------------
private ConversationUtils() {} // Private constructor as this is a utility class only with static methods
/**
* This method will close opened gui and writes question in chat. After players answers on question in chat, message

View File

@ -7,10 +7,10 @@
package world.bentobox.level.util;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.permissions.PermissionAttachmentInfo;
import java.util.List;
import java.util.stream.Collectors;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.hooks.LangUtilsHook;
@ -18,6 +18,10 @@ import world.bentobox.bentobox.hooks.LangUtilsHook;
public class Utils
{
private static final String LEVEL_MATERIALS = "level.materials.";
private Utils() {} // Private constructor as this is a utility class only with static methods
/**
* This method sends a message to the user with appended "prefix" text before message.
* @param user User who receives message.
@ -54,7 +58,7 @@ public class Utils
List<String> permissions = user.getEffectivePermissions().stream().
map(PermissionAttachmentInfo::getPermission).
filter(permission -> permission.startsWith(permPrefix)).
collect(Collectors.toList());
toList();
for (String permission : permissions)
{
@ -154,7 +158,7 @@ public class Utils
// materials:
// [material]:
// name: [name]
String translation = user.getTranslationOrNothing("level.materials." + object.name().toLowerCase() + ".name");
String translation = user.getTranslationOrNothing(LEVEL_MATERIALS + object.name().toLowerCase() + ".name");
if (!translation.isEmpty())
{
@ -167,7 +171,7 @@ public class Utils
// materials:
// [material]: [name]
translation = user.getTranslationOrNothing("level.materials." + object.name().toLowerCase());
translation = user.getTranslationOrNothing(LEVEL_MATERIALS + object.name().toLowerCase());
if (!translation.isEmpty())
{
@ -211,7 +215,7 @@ public class Utils
// materials:
// [material]:
// description: [text]
String translation = user.getTranslationOrNothing("level.materials." + object.name().toLowerCase() + ".description");
String translation = user.getTranslationOrNothing(LEVEL_MATERIALS + object.name().toLowerCase() + ".description");
if (!translation.isEmpty())
{

View File

@ -0,0 +1,165 @@
---
admin:
level:
parameters: "<speler>"
description: bereken het eiland level voor een speler
sethandicap:
parameters: "<speler> <handicap>"
description: stel handicap in voor het eiland, normaal gesproken het level van
het starter eiland.
changed: "&a Initiële handicap is veranderd van [number] naar [new_number]."
invalid-level: "&c Ongeldige handicap. Gebruik een getal."
levelstatus:
description: laat zien hoeveel eilanden er in de wachtrij staan voor het scannen
islands-in-queue: "&a Aantal eilanden in de wachtrij: [number]"
top:
description: Laat de top tien zien
unknown-world: "&c Ongeldige wereld!"
display: "&f[rank]. &a[name] &7- &b[level]"
remove:
description: verwijder speler van de top tien
parameters: "<speler>"
island:
level:
parameters: "[speler]"
description: bereken het eiland level voor [player]
calculating: "&a Level aan het berekenen..."
estimated-wait: "&a Verwachtte wachttijd: [number] seconde"
in-queue: "&a Jij staat op plek [number] in de wachtrij"
island-level-is: "&a Eiland level is &b[level]"
required-points-to-next-level: "&a [points] punten nodig voor het volgende level"
deaths: "&c([number] doodgegaan)"
cooldown: "&c Je moet nog &b[time] &c seconden wachten tot je dit weer kan doen."
in-progress: "&6 Eiland level wordt berekend..."
time-out: "&c De level berekening duurde te lang. Probeer het later opnieuw."
top:
description: Toon de Top tien
gui-title: "&a Top tien"
gui-heading: "&6[name]: &B[rank]"
island-level: "&b Level [level]"
warp-to: "&A Teleporteren naar [name]'s eiland"
level-details:
above-sea-level-blocks: 'Blokken boven zeeniveau '
spawners: Monsterkooien
underwater-blocks: Blokken onder zeeniveau
all-blocks: Alle blokken
no-island: "&c Geen eiland!"
names-island: "[name]'s eiland"
syntax: "[name] x [number]"
hint: "&c Gebruik level om het blokkenrapport te zien"
level:
commands:
value:
parameters: "[hand|<type>]"
description: toont de waarde van blokken. Voeg 'hand' toe aan het einde om de
waarde te laten zien van het item in je hand.
gui:
titles:
top: "&0&l Top eilanden"
detail-panel: "&0&l [name]'s eiland"
value-panel: "&0&l Blok waardes"
buttons:
island:
empty: "&f&l [name]. plaats"
name: "&f&l [name]"
description: |-
[owner]
[members]
[place]
[level]
owners-island: "[player]'s Eiland"
owner: "&7&l Eigenaar: &r&b [player]"
members-title: "&7&l Leden:"
member: "&b - [player]"
unknown: onbekend
place: "&7&o [number]. &r&7 plaats"
level: "&7 Level: &o [number]"
material:
name: "&f&l [number] x [material]"
description: |-
[description]
[count]
[value]
[calculated]
[limit]
[id]
id: "&7 Blok id: &e [id]"
value: "&7 Block waarde: &e [number]"
limit: "&7 Block limiet: &e [number]"
count: "&7 Aantal blokken: &e [number]"
calculated: "&7 Berekende waarde: &e [number]"
all_blocks:
name: "&f&l Alle Blokken"
description: "&7 Toon alle blokken \n&7 op het eiland."
above_sea_level:
name: "&f&l Blokken boven zeeniveau"
description: |-
&7 Toon alleen blokken
&7 die boven zeeniveau zijn
underwater:
name: "&f&l Blokken onder zeeniveau"
description: |-
&7 Toon alleen blokken
&7 die onder zeeniveau zijn
spawner:
name: "&f&l Monsterkooien"
description: "&7 Toon alleen monsterkooien."
filters:
name:
name: "&f&l Sorteer aan de hand van naam"
description: "&7 Sorteer alle blokken aan de hand van naam."
value:
name: "&f&l Sorteer aan de hand van waarde"
description: "&7 Sorteer alle blokken aan de hand van waarde."
count:
name: "&f&l Sorteer aan de hand van aantal"
description: "&7 Sorteer alle blokken aan de hand van aantal."
value:
name: "&f&l [material]"
description: |-
[description]
[value]
[underwater]
[limit]
[id]
id: "&7 Blok id: &e [id]"
value: "&7 Block waarrde: &e [number]"
underwater: "&7 Onder zeeniveau: &e [number]"
limit: "&7 Blok limiet: &e [number]"
previous:
name: "&f&l Vorige pagina"
description: "&7 Ga naar pagina [number]"
next:
name: "&f&l Volgende pagina"
description: "&7 Ga naar pagina [number]"
search:
name: "&f&l Zoek"
description: "&7 Zoek voor een \n&7 specifieke waarde."
search: "&b Waarde: [value]"
tips:
click-to-view: "&e Klik &7 om te zien."
click-to-previous: "&e Klik &7 om de vorige pagina te zien."
click-to-next: "&e Klik &7 om de volgende pagina te zien."
click-to-select: "&e Klik &7 om te selecteren."
left-click-to-cycle-up: "&e Linker Klik &7 om door te lopen."
right-click-to-cycle-down: "&e Rechter Klik &7 om terug door te lopen."
left-click-to-change: "&e Linker Klik &7 om bij te werken."
right-click-to-clear: "&e Linker Klik &7 om te verwijderen."
click-to-asc: "&e Klik &7 om te toenemend te sorteren."
click-to-desc: "&e Klik &7 om te afnemenend te sorteren."
click-to-warp: "&e Klik &7 om te teleporteren."
click-to-visit: "&e Klik &7 om te bezoeken."
right-click-to-visit: "&e Rechter Klik &7 om te bezoeken."
conversations:
prefix: "&l&6 [BentoBox]: &r"
no-data: "&c Gebruik level om het blokkenrapport te zien."
cancel-string: stop
exit-string: stop
write-search: "&e Schrijf een zoekopdracht. (Schrijf 'stop' om te zoeken)"
search-updated: "&a Zoekopdracht bijgewerkt."
cancelled: "&c Conversatie gestopt!"
no-value: "&c Dit item heeft geen waarde."
unknown-item: "&c '[material]' bestaat niet in het spel."
value: "&7 De waarde van '[material]' is: &e[value]"
value-underwater: "&7 The waarde van '[material]' onder zeeniveau: &e[value]"
empty-hand: "&c Je hebt geen blok vast"

View File

@ -2,53 +2,162 @@
admin:
level:
parameters: "<player>"
description: 计算玩家的岛屿等级
description: 计算指定玩家的岛屿等级
sethandicap:
parameters: "<玩家> <让分>"
description: 设置孤岛障碍,通常是首发岛的水平
changed: "a初始离岛差由[number]更改为[new_number]。"
invalid-level: "c差点。使用整数。"
parameters: "<player> <handicap>"
description: 设置偏差值,通常用于调整新建的初始岛屿等级为零。实际岛屿等级 - <handicap> = 计算的岛屿等级
changed: "&a 岛屿的偏差值从 [number] 更改为 [new_number]"
invalid-level: "&c 偏差值无效,请使用整数"
levelstatus:
description: 显示要扫描的队列中有多少岛
islands-in-queue: "a列队中的列队[人数]"
description: 显示等级计算队列中的岛屿
islands-in-queue: "&a 列队中的岛屿:[number]"
top:
description: 显示前十名
unknown-world: "&c未知世界!"
unknown-world: "&c 未知的世界!"
display: "&f[rank]. &a[name] &7- &b[level]"
remove:
description: 将玩家移出前十
description: 将玩家移出前十
parameters: "<player>"
island:
level:
parameters: "[player]"
description: 计算你或玩家 [player] 的岛屿等级
calculating: "&a计算等级中..."
estimated-wait: "&a 预计等待时间: [number] 秒"
in-queue: "a您是队列中的数字[number]"
description: 计算你或指定玩家 [player] 的岛屿等级
calculating: "&a 等级计算中..."
estimated-wait: "&a 预计等待时间[number] 秒"
in-queue: "&a 你处于队列中第 [number] 个"
island-level-is: "&a 岛屿等级为 &b[level]"
required-points-to-next-level: "&a还需 [points] 才能到下一级"
required-points-to-next-level: "&a 还需 [points] 点数才能到下一级"
deaths: "&c([number] 次死亡)"
cooldown: "&c再等 &b[time] &c秒才能再次使用"
in-progress: "6岛级计算正在进行中..."
time-out: "c等级计算花了太长时间。请稍后再试。"
cooldown: "&c 还需等待 &b[time] &c秒才能再次使用该指令"
in-progress: "&6 岛级等级正在计算中..."
time-out: "&c 等级计算超时。请稍后再试"
top:
description: 显示前十名
gui-title: "&a 前十"
gui-heading: "&6[name]: &B[rank]"
island-level: "&B等级 [level]"
warp-to: "&A正传送到 [name] 的岛屿"
island-level: "&b 等级 [level]"
warp-to: "&a 正在传送到 [name] 的岛屿"
level-details:
above-sea-level-blocks: 海拔以上的街区
spawners: 产卵者
underwater-blocks: 水下积木
all-blocks: 所有块
no-island: "c没有岛"
names-island: "[名字]的小岛"
syntax: "[名称] x [数字]"
hint: "c运行级别以查看阻止报告"
above-sea-level-blocks: 海平面以上的方块
spawners: 刷怪笼
underwater-blocks: 水下的方块
all-blocks: 所有方块
no-island: "&c 没有岛屿!"
names-island: "[name] 的岛屿"
syntax: "[name] x [number]"
hint: "&c 运行level指令查看方块报告"
level:
commands:
value:
description: 查看某方块的价值
success: "&7本方块的价值: &e[value]"
success-underwater: "&7本方块的水下价值: &e[value]"
empty-hand: "&c你手里没有方块"
no-value: "&c这个东西一文不值."
parameters: "[hand|<material>]"
description: 显示方块的价值。在末尾添加 'hand' 可显示手中方块的价值
gui:
titles:
top: "&0&l 岛屿排行榜"
detail-panel: "&0&l [name] 的岛屿"
value-panel: "&0&l 方块价值"
buttons:
island:
empty: "&f&l 第 [name] 名"
name: "&f&l [name]"
description: |-
[owner]
[members]
[place]
[level]
owners-island: "[player] 的岛屿"
owner: "&7&l 岛主:&r&b [player]"
members-title: "&7&l 成员:"
member: "&b - [player]"
unknown: 未知
place: "&7第 &7&o[number] &r&7名"
level: "&7 等级: &o [number]"
material:
name: "&f&l [number] x [material]"
description: |-
[description]
[count]
[value]
[calculated]
[limit]
[id]
id: "&7 方块ID&e [id]"
value: "&7 方块价值:&e [number]"
limit: "&7 方块限制:&e [number]"
count: "&7 方块数量:&e [number]"
calculated: "&7 计算值:&e [number]"
all_blocks:
name: "&f&l 所有方块"
description: "&7 显示岛屿上所有的方块"
above_sea_level:
name: "&f&l 方块在海平面以上的价值"
description: |-
&7 只显示所有
&7 海平面以上的方块
underwater:
name: "&f&l 海平面以下的方块"
description: |-
&7 只显示所有
&7 海平面以下的方块
spawner:
name: "&f&l 刷怪笼"
description: "&7 只显示刷怪笼"
filters:
name:
name: "&f&l 按名称排序"
description: "&7 通过名称排序所有的方块"
value:
name: "&f&l 按价值排序"
description: "&7 通过价值排序所有的方块"
count:
name: "&f&l 按数量排序"
description: "&7 通过数量排序所有方块"
value:
name: "&f&l [material]"
description: |-
[description]
[value]
[underwater]
[limit]
[id]
id: "&7 方块ID&e [id]"
value: "&7 方块价值:&e [number]"
underwater: "&7 方块海平面下价值:&e [number]"
limit: "&7 方块限制:&e [number]"
previous:
name: "&f&l 上一页"
description: "&7 切换到第 [number] 页"
next:
name: "&f&l 下一页"
description: "&7 切换到第 [number] 页"
search:
name: "&f&l 搜索"
description: "&7 搜索特定的内容"
search: "&b 搜索值:[value]"
tips:
click-to-view: "&e 点击 &7 查看"
click-to-previous: "&e 点击 &7 查看上一页"
click-to-next: "&e 点击 &7 查看下一页"
click-to-select: "&e 点击 &7 选择"
left-click-to-cycle-up: "&e 左键点击 &7 向上循环"
right-click-to-cycle-down: "&e 右键点击 &7 向下循环"
left-click-to-change: "&e 左键点击 &7 编辑"
right-click-to-clear: "&e 右键点击 &7 清除"
click-to-asc: "&e 点击 &7 以升序排序"
click-to-desc: "&e 点击 &7 以降序排序"
click-to-warp: "&e 点击 &7 去岛屿传送点"
click-to-visit: "&e 点击 &7 参观"
right-click-to-visit: "&e 右键点击 &7 查看"
conversations:
prefix: "&l&6 [BentoBox]: &r"
no-data: "&c 运行level指令查看方块报告"
cancel-string: cancel
exit-string: cancel, exit, quit
write-search: "&e 请输入要搜索的值. (输入 'cancel' 退出)"
search-updated: "&a 搜索值已更新"
cancelled: "&c 对话已取消!"
no-value: "&c 这件物品一文不值"
unknown-item: "&c 物品 '[material]' 在游戏中不存在"
value: "&7 物品 '[material]' 的价值:&e[value]"
value-underwater: "&7 物品 '[material]' 在海平面以下的价值:&e[value]"
empty-hand: "&c 你的手中没有拿着方块"

View File

@ -166,7 +166,7 @@ public class LevelsManagerTest {
// Default to uuid's being island owners
when(im.isOwner(eq(world), any())).thenReturn(true);
when(im.getOwner(any(), any(UUID.class))).thenAnswer(in -> in.getArgument(1, UUID.class));
when(im.getIsland(eq(world), eq(uuid))).thenReturn(island);
when(im.getIsland(world, uuid)).thenReturn(island);
when(im.getIslandById(anyString())).thenReturn(Optional.of(island));
// Player
@ -392,8 +392,8 @@ public class LevelsManagerTest {
Bukkit.getScheduler();
verify(scheduler).runTaskAsynchronously(eq(plugin), task.capture());
task.getValue().run();
verify(addon).log(eq("Generating rankings"));
verify(addon).log(eq("Generated rankings for bskyblock-world"));
verify(addon).log("Generating rankings");
verify(addon).log("Generated rankings for bskyblock-world");
}

View File

@ -164,7 +164,7 @@ public class AdminTopRemoveCommandTest {
@Test
public void testCanExecuteWrongArgs() {
assertFalse(atrc.canExecute(user, "delete", Collections.emptyList()));
verify(user).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock"));
verify(user).sendMessage("commands.help.header", TextVariables.LABEL, "BSkyBlock");
}
/**
@ -174,7 +174,7 @@ public class AdminTopRemoveCommandTest {
public void testCanExecuteUnknown() {
when(pm.getUser(anyString())).thenReturn(null);
assertFalse(atrc.canExecute(user, "delete", Collections.singletonList("tastybento")));
verify(user).sendMessage(eq("general.errors.unknown-player"), eq(TextVariables.NAME), eq("tastybento"));
verify(user).sendMessage("general.errors.unknown-player", TextVariables.NAME, "tastybento");
}
/**
@ -193,7 +193,7 @@ public class AdminTopRemoveCommandTest {
testCanExecuteKnown();
assertTrue(atrc.execute(user, "delete", Collections.singletonList("tastybento")));
verify(manager).removeEntry(any(World.class), eq(uuid));
verify(user).sendMessage(eq("general.success"));
verify(user).sendMessage("general.success");
}
}