Code cleanup (#2065)

* Cast operands to (double)

* Code clean up from static analysis

* Revert the GitHubAPI version change because it didn't work.
This commit is contained in:
tastybento 2022-12-29 10:01:25 -08:00 committed by GitHub
parent 70262be896
commit 18983e5570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
88 changed files with 494 additions and 417 deletions

View File

@ -77,10 +77,10 @@
<!-- Might differ from the last Spigot release for short periods
of time -->
<paper.version>1.19-R0.1-SNAPSHOT</paper.version>
<bstats.version>2.2.1</bstats.version>
<bstats.version>3.0.0</bstats.version>
<vault.version>1.7.1</vault.version>
<placeholderapi.version>2.10.9</placeholderapi.version>
<githubapi.version>25f6c5c571</githubapi.version>
<githubapi.version>d5f5e0bbd8</githubapi.version>
<dynmap.version>3.0-SNAPSHOT</dynmap.version>
<myworlds.version>1.19-v2</myworlds.version>
<!-- Revision variable removes warning about dynamic version -->

View File

@ -28,9 +28,9 @@ import world.bentobox.bentobox.listeners.BlockEndDragon;
import world.bentobox.bentobox.listeners.DeathListener;
import world.bentobox.bentobox.listeners.JoinLeaveListener;
import world.bentobox.bentobox.listeners.PanelListenerManager;
import world.bentobox.bentobox.listeners.StandardSpawnProtectionListener;
import world.bentobox.bentobox.listeners.teleports.EntityTeleportListener;
import world.bentobox.bentobox.listeners.teleports.PlayerTeleportListener;
import world.bentobox.bentobox.listeners.StandardSpawnProtectionListener;
import world.bentobox.bentobox.managers.AddonsManager;
import world.bentobox.bentobox.managers.BlueprintsManager;
import world.bentobox.bentobox.managers.CommandsManager;

View File

@ -287,7 +287,7 @@ public final class AddonDescription {
*/
@Override
public String toString() {
return "AddonDescription [" + (name != null ? "name=" + name + ", " : "")
return "AddonDescription [" + "name=" + name + ", "
+ "version=" + version + "]";
}
}

View File

@ -11,7 +11,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.bukkit.World;
import org.bukkit.command.Command;
@ -286,10 +285,10 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
{
// Check perms, but only if this isn't the console
if (user.isPlayer() &&
!user.isOp() &&
this.getPermission() != null &&
!this.getPermission().isEmpty() &&
!user.hasPermission(this.getPermission()))
!user.isOp() &&
this.getPermission() != null &&
!this.getPermission().isEmpty() &&
!user.hasPermission(this.getPermission()))
{
user.sendMessage("general.errors.no-permission", TextVariables.PERMISSION, this.getPermission());
return false;
@ -519,7 +518,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
* @param user - the User
* @return true if sender is a player
* @deprecated use {@link User#isPlayer()}
* @forRemove 1.18.0
* @forRemoval 1.18.0
*/
@Deprecated
protected boolean isPlayer(User user) {
@ -663,7 +662,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
/* ------------ */
String lastArg = args.length != 0 ? args[args.length - 1] : "";
return Util.tabLimit(options, lastArg).stream().sorted().collect(Collectors.toList());
return Util.tabLimit(options, lastArg).stream().sorted().toList();
}
/**
@ -677,7 +676,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
return command.getSubCommands().values().stream()
.filter(cmd -> !cmd.isHidden())
.filter(cmd -> !cmd.isOnlyPlayer() || sender.isOp() || (sender instanceof Player && cmd.getPermission() != null && (cmd.getPermission().isEmpty() || sender.hasPermission(cmd.getPermission()))) )
.map(CompositeCommand::getLabel).collect(Collectors.toList());
.map(CompositeCommand::getLabel).toList();
}
/**

View File

@ -83,7 +83,7 @@ public class AdminDeleteCommand extends ConfirmableCommand {
// Remove them from this island (it still exists and will be deleted later)
getIslands().removePlayer(getWorld(), targetUUID);
if (target.isPlayer() && target.isOnline()) {
cleanUp(user, target);
cleanUp(target);
}
vector = oldIsland.getCenter().toVector();
getIslands().deleteIsland(oldIsland, true, targetUUID);
@ -95,7 +95,7 @@ public class AdminDeleteCommand extends ConfirmableCommand {
}
}
private void cleanUp(User user, User target) {
private void cleanUp(User target) {
// Remove money inventory etc.
if (getIWM().isOnLeaveResetEnderChest(getWorld())) {
target.getPlayer().getEnderChest().clear();

View File

@ -55,11 +55,11 @@ public class AdminDeleteHomesCommand extends ConfirmableCommand {
return false;
}
// Confirm
askConfirmation(user, user.getTranslation("commands.admin.deletehomes.warning"), () -> deleteHomes(user, targetUUID, island));
askConfirmation(user, user.getTranslation("commands.admin.deletehomes.warning"), () -> deleteHomes(user, island));
return true;
}
private boolean deleteHomes(User user, UUID targetUUID, Island island) {
private boolean deleteHomes(User user, Island island) {
island.removeHomes();
user.sendMessage("general.success");
return true;

View File

@ -3,7 +3,6 @@ package world.bentobox.bentobox.api.commands.admin;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -98,7 +97,7 @@ public class AdminGetrankCommand extends CompositeCommand {
return Optional.empty();
}
String lastArg = args.get(args.size() - 1);
List<String> options = Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
List<String> options = Bukkit.getOnlinePlayers().stream().map(Player::getName).toList();
return Optional.of(Util.tabLimit(options, lastArg));
}
}

View File

@ -3,7 +3,6 @@ package world.bentobox.bentobox.api.commands.admin;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.stream.Collectors;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
@ -26,7 +25,7 @@ public class AdminResetFlagsCommand extends ConfirmableCommand {
super(parent, "resetflags");
options = getPlugin().getFlagsManager().getFlags().stream()
.filter(f -> f.getType().equals(Type.PROTECTION) || f.getType().equals(Type.SETTING))
.map(Flag::getID).collect(Collectors.toList());
.map(Flag::getID).toList();
}
@Override

View File

@ -1,10 +1,11 @@
package world.bentobox.bentobox.api.commands.admin;
import org.eclipse.jdt.annotation.Nullable;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;

View File

@ -50,7 +50,7 @@ public class AdminSetProtectionCenterCommand extends ConfirmableCommand
public boolean canExecute(User user, String label, List<String> args) {
if (args.size() == 3) {
// Get location
targetLoc = getLocation(user, args);
targetLoc = getLocation(args);
} else {
targetLoc = new Location(getWorld(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ());
}
@ -67,7 +67,7 @@ public class AdminSetProtectionCenterCommand extends ConfirmableCommand
return true;
}
private Location getLocation(User user, List<String> args) {
private Location getLocation(List<String> args) {
try {
int x = Integer.parseInt(args.get(0));
int y = Integer.parseInt(args.get(1));

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.Nullable;
@ -140,7 +139,7 @@ public class AdminSetrankCommand extends CompositeCommand {
return Optional.of(getPlugin().getRanksManager().getRanks()
.entrySet().stream()
.filter(entry -> entry.getValue() > RanksManager.VISITOR_RANK)
.map(entry -> user.getTranslation(entry.getKey())).collect(Collectors.toList()));
.map(entry -> user.getTranslation(entry.getKey())).toList());
}
// Return the player names again for the optional island owner argument

View File

@ -8,7 +8,6 @@ import java.util.Locale;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.ChatColor;
import org.eclipse.jdt.annotation.NonNull;
@ -192,19 +191,17 @@ public class AdminSettingsCommand extends CompositeCommand {
// Command line setting
flag.ifPresent(f -> {
switch (f.getType()) {
case PROTECTION:
island.setFlag(f, rank);
getIslands().save(island);
break;
case SETTING:
island.setSettingsFlag(f, activeState);
getIslands().save(island);
break;
case WORLD_SETTING:
f.setSetting(getWorld(), activeState);
break;
default:
break;
case PROTECTION -> {
island.setFlag(f, rank);
getIslands().save(island);
}
case SETTING -> {
island.setSettingsFlag(f, activeState);
getIslands().save(island);
}
case WORLD_SETTING -> f.setSetting(getWorld(), activeState);
default -> {
}
}
});
user.sendMessage("general.success");
@ -270,7 +267,7 @@ public class AdminSettingsCommand extends CompositeCommand {
.getRanks().entrySet().stream()
.filter(en -> en.getValue() > RanksManager.BANNED_RANK && en.getValue() <= RanksManager.OWNER_RANK)
.map(Entry::getKey)
.map(user::getTranslation).collect(Collectors.toList());
.map(user::getTranslation).toList();
case SETTING -> Arrays.asList(active, disabled);
default -> Collections.<String>emptyList();
}).orElse(Collections.emptyList());

View File

@ -9,7 +9,12 @@ import world.bentobox.bentobox.api.commands.admin.deaths.AdminDeathsCommand;
import world.bentobox.bentobox.api.commands.admin.purge.AdminPurgeCommand;
import world.bentobox.bentobox.api.commands.admin.range.AdminRangeCommand;
import world.bentobox.bentobox.api.commands.admin.resets.AdminResetsCommand;
import world.bentobox.bentobox.api.commands.admin.team.*;
import world.bentobox.bentobox.api.commands.admin.team.AdminTeamAddCommand;
import world.bentobox.bentobox.api.commands.admin.team.AdminTeamCommand;
import world.bentobox.bentobox.api.commands.admin.team.AdminTeamDisbandCommand;
import world.bentobox.bentobox.api.commands.admin.team.AdminTeamFixCommand;
import world.bentobox.bentobox.api.commands.admin.team.AdminTeamKickCommand;
import world.bentobox.bentobox.api.commands.admin.team.AdminTeamSetownerCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;

View File

@ -2,7 +2,6 @@ package world.bentobox.bentobox.api.commands.admin.blueprints;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import world.bentobox.bentobox.api.commands.ConfirmableCommand;

View File

@ -2,13 +2,11 @@ package world.bentobox.bentobox.api.commands.admin.blueprints;
import java.io.File;
import java.util.List;
import java.util.Locale;
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.blueprints.Blueprint;
import world.bentobox.bentobox.blueprints.BlueprintClipboard;
import world.bentobox.bentobox.managers.BlueprintsManager;
import world.bentobox.bentobox.util.Util;

View File

@ -99,10 +99,10 @@ public class AdminRangeDisplayCommand extends CompositeCommand {
// Draw 3 "stages" (one line below, at and above player's y coordinate)
for (int stage = -1 ; stage <= 1 ; stage++) {
for (int i = -range ; i <= range ; i++) {
user.spawnParticle(particle, dustOptions, center.getBlockX() + i, playerY + stage, center.getBlockZ() + range);
user.spawnParticle(particle, dustOptions, center.getBlockX() + i, playerY + stage, center.getBlockZ() - range);
user.spawnParticle(particle, dustOptions, center.getBlockX() + range, playerY + stage, center.getBlockZ() + i);
user.spawnParticle(particle, dustOptions, center.getBlockX() - range, playerY + stage, center.getBlockZ() + i);
user.spawnParticle(particle, dustOptions, (double)center.getBlockX() + i, (double)playerY + stage, (double)center.getBlockZ() + range);
user.spawnParticle(particle, dustOptions, (double)center.getBlockX() + i, (double)playerY + stage, (double)center.getBlockZ() - range);
user.spawnParticle(particle, dustOptions, (double)center.getBlockX() + range, (double)playerY + stage, (double)center.getBlockZ() + i);
user.spawnParticle(particle, dustOptions, (double)center.getBlockX() - range, (double)playerY + stage, (double)center.getBlockZ() + i);
}
}
}

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
@ -142,7 +141,7 @@ public class IslandBanCommand extends CompositeCommand {
.filter(p -> !p.getUniqueId().equals(user.getUniqueId()))
.filter(p -> !island.isBanned(p.getUniqueId()))
.filter(p -> user.getPlayer().canSee(p))
.map(Player::getName).collect(Collectors.toList());
.map(Player::getName).toList();
return Optional.of(Util.tabLimit(options, lastArg));
} else {
return Optional.empty();

View File

@ -3,7 +3,6 @@ package world.bentobox.bentobox.api.commands.island;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
@ -57,7 +56,7 @@ public class IslandBanlistCommand extends CompositeCommand {
// Title
user.sendMessage("commands.island.banlist.the-following");
// Create a nicely formatted list
List<String> names = island.getBanned().stream().map(u -> getPlayers().getName(u)).sorted().collect(Collectors.toList());
List<String> names = island.getBanned().stream().map(u -> getPlayers().getName(u)).sorted().toList();
List<String> lines = new ArrayList<>();
StringBuilder line = new StringBuilder();
// Put the names into lines of no more than 40 characters long, separated by commas

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
@ -156,7 +155,7 @@ public class IslandExpelCommand extends CompositeCommand {
.filter(p -> !p.isOp()) // Not op
.filter(p -> !p.hasPermission(this.getPermissionPrefix() + "admin.noexpel"))
.filter(p -> !p.hasPermission(this.getPermissionPrefix() + "mod.bypassexpel"))
.map(Player::getName).collect(Collectors.toList());
.map(Player::getName).toList();
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
return Optional.of(Util.tabLimit(options, lastArg));

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.Nullable;
@ -112,7 +111,7 @@ public class IslandUnbanCommand extends CompositeCommand {
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
if (island != null) {
List<String> options = island.getBanned().stream().map(getPlayers()::getName).collect(Collectors.toList());
List<String> options = island.getBanned().stream().map(getPlayers()::getName).toList();
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
return Optional.of(Util.tabLimit(options, lastArg));
} else {

View File

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -108,7 +107,7 @@ public class IslandTeamCommand extends CompositeCommand {
// We now need to get all online "members" of the island - incl. Trusted and coop
List<UUID> onlineMembers = island.getMemberSet(RanksManager.COOP_RANK).stream()
.filter(uuid -> Util.getOnlinePlayerList(user).contains(Bukkit.getOfflinePlayer(uuid).getName())).collect(Collectors.toList());
.filter(uuid -> Util.getOnlinePlayerList(user).contains(Bukkit.getOfflinePlayer(uuid).getName())).toList();
for (int rank : ranks) {
Set<UUID> players = island.getMemberSet(rank, false);

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -131,7 +130,7 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
List<String> options = island.getMemberSet().stream()
.filter(uuid -> island.getRank(uuid) >= RanksManager.MEMBER_RANK)
.map(Bukkit::getOfflinePlayer)
.map(OfflinePlayer::getName).collect(Collectors.toList());
.map(OfflinePlayer::getName).toList();
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
return Optional.of(Util.tabLimit(options, lastArg));

View File

@ -3,7 +3,6 @@ package world.bentobox.bentobox.api.commands.island.team;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -125,7 +124,7 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
if (island != null) {
List<String> options = island.getMemberSet().stream()
.map(Bukkit::getOfflinePlayer)
.map(OfflinePlayer::getName).collect(Collectors.toList());
.map(OfflinePlayer::getName).toList();
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
return Optional.of(Util.tabLimit(options, lastArg));

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -114,7 +113,7 @@ public class IslandTeamUncoopCommand extends CompositeCommand {
List<String> options = island.getMembers().entrySet().stream()
.filter(e -> e.getValue() == RanksManager.COOP_RANK)
.map(e -> Bukkit.getOfflinePlayer(e.getKey()))
.map(OfflinePlayer::getName).collect(Collectors.toList());
.map(OfflinePlayer::getName).toList();
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
return Optional.of(Util.tabLimit(options, lastArg));
} else {

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -114,7 +113,7 @@ public class IslandTeamUntrustCommand extends CompositeCommand {
List<String> options = island.getMembers().entrySet().stream()
.filter(e -> e.getValue() == RanksManager.TRUSTED_RANK)
.map(e -> Bukkit.getOfflinePlayer(e.getKey()))
.map(OfflinePlayer::getName).collect(Collectors.toList());
.map(OfflinePlayer::getName).toList();
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
return Optional.of(Util.tabLimit(options, lastArg));
} else {

View File

@ -1,11 +1,11 @@
package world.bentobox.bentobox.api.flags.clicklisteners;
import java.util.Objects;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.event.inventory.ClickType;
import java.util.Objects;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.events.flags.FlagProtectionChangeEvent;

View File

@ -1,11 +1,11 @@
package world.bentobox.bentobox.api.flags.clicklisteners;
import java.util.Objects;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.event.inventory.ClickType;
import java.util.Objects;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.events.flags.FlagSettingChangeEvent;

View File

@ -8,7 +8,11 @@ package world.bentobox.bentobox.api.panels.builders;
import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import org.bukkit.World;

View File

@ -17,8 +17,6 @@ import org.bukkit.inventory.ItemStack;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.api.panels.reader.ItemTemplateRecord.ActionRecords;
/**
* This Record contains all necessary information about Item Template that can be used to craft panel item.
@ -33,11 +31,11 @@ import world.bentobox.bentobox.api.panels.reader.ItemTemplateRecord.ActionRecord
* @since 1.17.3
*/
public record ItemTemplateRecord(@Nullable ItemStack icon,
@Nullable String title,
@Nullable String description,
@NonNull List<ActionRecords> actions,
@NonNull Map<String, Object> dataMap,
@Nullable ItemTemplateRecord fallback)
@Nullable String title,
@Nullable String description,
@NonNull List<ActionRecords> actions,
@NonNull Map<String, Object> dataMap,
@Nullable ItemTemplateRecord fallback)
{
/**
* Instantiates a new Item template record without actions and data map.

View File

@ -15,7 +15,6 @@ import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.api.panels.Panel;
import world.bentobox.bentobox.api.panels.reader.PanelTemplateRecord.TemplateItem;
/**
@ -98,10 +97,9 @@ public record PanelTemplateRecord(Panel.Type type,
if (this == obj) {
return true;
}
if (!(obj instanceof PanelTemplateRecord)) {
if (!(obj instanceof PanelTemplateRecord other)) {
return false;
}
PanelTemplateRecord other = (PanelTemplateRecord) obj;
return Objects.equals(background, other.background) && Objects.equals(border, other.border)
&& Arrays.deepEquals(content, other.content) && Arrays.equals(forcedRows, other.forcedRows)
&& Objects.equals(title, other.title) && type == other.type;

View File

@ -6,6 +6,12 @@
package world.bentobox.bentobox.api.panels.reader;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
@ -14,12 +20,6 @@ import org.bukkit.event.inventory.ClickType;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.base.Enums;
import world.bentobox.bentobox.api.panels.Panel;

View File

@ -8,7 +8,6 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.Bukkit;
@ -330,7 +329,7 @@ public class User implements MetaDataAble {
.filter(PermissionAttachmentInfo::getValue) // Must be a positive permission, not a negative one
.map(PermissionAttachmentInfo::getPermission)
.filter(permission -> permission.startsWith(permPrefix))
.collect(Collectors.toList());
.toList();
if (permissions.isEmpty()) return defaultValue;
@ -414,9 +413,7 @@ public class User implements MetaDataAble {
}
// If this is a prefix, just gather and return the translation
if (reference.startsWith("prefixes.")) {
return translation;
} else {
if (!reference.startsWith("prefixes.")) {
// Replace the prefixes
for (String prefix : plugin.getLocalesManager().getAvailablePrefixes(this)) {
String prefixTranslation = getTranslation("prefixes." + prefix);
@ -441,8 +438,8 @@ public class User implements MetaDataAble {
translation = plugin.getPlaceholdersManager().replacePlaceholders(player, translation);
}
return translation;
}
return translation;
}
/**
@ -605,67 +602,68 @@ public class User implements MetaDataAble {
// Improve particle validation.
switch (particle)
{
case REDSTONE ->
case REDSTONE ->
{
if (!(dustOptions instanceof Particle.DustOptions))
{
if (!(dustOptions instanceof Particle.DustOptions))
{
throw new IllegalArgumentException("A non-null Particle.DustOptions must be provided when using Particle.REDSTONE as particle.");
}
throw new IllegalArgumentException("A non-null Particle.DustOptions must be provided when using Particle.REDSTONE as particle.");
}
case ITEM_CRACK ->
}
case ITEM_CRACK ->
{
if (!(dustOptions instanceof ItemStack))
{
if (!(dustOptions instanceof ItemStack))
{
throw new IllegalArgumentException("A non-null ItemStack must be provided when using Particle.ITEM_CRACK as particle.");
}
throw new IllegalArgumentException("A non-null ItemStack must be provided when using Particle.ITEM_CRACK as particle.");
}
case BLOCK_CRACK, BLOCK_DUST, FALLING_DUST, BLOCK_MARKER ->
}
case BLOCK_CRACK, BLOCK_DUST, FALLING_DUST, BLOCK_MARKER ->
{
if (!(dustOptions instanceof BlockData))
{
if (!(dustOptions instanceof BlockData))
{
throw new IllegalArgumentException("A non-null BlockData must be provided when using Particle." + particle + " as particle.");
}
throw new IllegalArgumentException("A non-null BlockData must be provided when using Particle." + particle + " as particle.");
}
case DUST_COLOR_TRANSITION ->
}
case DUST_COLOR_TRANSITION ->
{
if (!(dustOptions instanceof Particle.DustTransition))
{
if (!(dustOptions instanceof Particle.DustTransition))
{
throw new IllegalArgumentException("A non-null Particle.DustTransition must be provided when using Particle.DUST_COLOR_TRANSITION as particle.");
}
throw new IllegalArgumentException("A non-null Particle.DustTransition must be provided when using Particle.DUST_COLOR_TRANSITION as particle.");
}
case VIBRATION ->
}
case VIBRATION ->
{
if (!(dustOptions instanceof Vibration))
{
if (!(dustOptions instanceof Vibration))
{
throw new IllegalArgumentException("A non-null Vibration must be provided when using Particle.VIBRATION as particle.");
}
throw new IllegalArgumentException("A non-null Vibration must be provided when using Particle.VIBRATION as particle.");
}
case SCULK_CHARGE ->
}
case SCULK_CHARGE ->
{
if (!(dustOptions instanceof Float))
{
if (!(dustOptions instanceof Float))
{
throw new IllegalArgumentException("A non-null Float must be provided when using Particle.SCULK_CHARGE as particle.");
}
throw new IllegalArgumentException("A non-null Float must be provided when using Particle.SCULK_CHARGE as particle.");
}
case SHRIEK ->
}
case SHRIEK ->
{
if (!(dustOptions instanceof Integer))
{
if (!(dustOptions instanceof Integer))
{
throw new IllegalArgumentException("A non-null Integer must be provided when using Particle.SHRIEK as particle.");
}
throw new IllegalArgumentException("A non-null Integer must be provided when using Particle.SHRIEK as particle.");
}
case LEGACY_BLOCK_CRACK, LEGACY_BLOCK_DUST, LEGACY_FALLING_DUST ->
}
case LEGACY_BLOCK_CRACK, LEGACY_BLOCK_DUST, LEGACY_FALLING_DUST ->
{
if (!(dustOptions instanceof BlockData))
{
if (!(dustOptions instanceof BlockData))
{
throw new IllegalArgumentException("A non-null MaterialData must be provided when using Particle." + particle + " as particle.");
}
throw new IllegalArgumentException("A non-null MaterialData must be provided when using Particle." + particle + " as particle.");
}
}
default -> throw new IllegalArgumentException("Unexpected value: " + particle);
}
// Check if this particle is beyond the viewing distance of the server
if (this.player != null &&
this.player.getLocation().toVector().distanceSquared(new Vector(x, y, z)) <
this.player.getLocation().toVector().distanceSquared(new Vector(x, y, z)) <
(Bukkit.getServer().getViewDistance() * 256 * Bukkit.getServer().getViewDistance()))
{
if (particle.equals(Particle.REDSTONE))

View File

@ -2,7 +2,6 @@ package world.bentobox.bentobox.blueprints;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.bukkit.Material;

View File

@ -8,7 +8,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -138,7 +137,7 @@ public class BlueprintClipboard {
.filter(e -> new Vector(Math.rint(e.getLocation().getX()),
Math.rint(e.getLocation().getY()),
Math.rint(e.getLocation().getZ())).equals(v))
.collect(Collectors.toList());
.toList();
if (copyBlock(v.toLocation(world), copyAir, copyBiome, ents)) {
count++;
}

View File

@ -1,5 +1,17 @@
package world.bentobox.bentobox.blueprints;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@ -7,6 +19,7 @@ import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
@ -16,12 +29,6 @@ import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.nms.PasteHandler;
import world.bentobox.bentobox.util.Util;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
/**
* This class pastes the clipboard it is given
* @author tastybento

View File

@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.blueprints.Blueprint;

View File

@ -3,7 +3,6 @@ package world.bentobox.bentobox.blueprints.dataobjects;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.bukkit.Material;

View File

@ -26,7 +26,6 @@ import world.bentobox.bentobox.database.json.adapters.LocationTypeAdapter;
import world.bentobox.bentobox.database.json.adapters.PotionEffectTypeAdapter;
import world.bentobox.bentobox.database.json.adapters.VectorTypeAdapter;
import world.bentobox.bentobox.database.json.adapters.WorldTypeAdapter;
import world.bentobox.bentobox.versions.ServerCompatibility;
/**

View File

@ -5,9 +5,6 @@ import com.google.gson.annotations.Expose;
/**
* Record for bonus ranges
* @author tastybento
* @param id an id to identify this bonus
* @param range the additional bonus range
* @param message the reference key to a locale message related to this bonus. May be blank.
*/
public class BonusRangeRecord {
@Expose
@ -17,9 +14,9 @@ public class BonusRangeRecord {
@Expose
private String message;
/**
* @param uniqueId
* @param range
* @param message
* @param uniqueId an id to identify this bonus
* @param range the additional bonus range
* @param message the reference key to a locale message related to this bonus. May be blank.
*/
public BonusRangeRecord(String uniqueId, int range, String message) {
this.uniqueId = uniqueId;

View File

@ -16,9 +16,9 @@ import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.GameMode;
import org.bukkit.World.Environment;
import org.bukkit.entity.Player;
import org.bukkit.util.BoundingBox;
@ -728,10 +728,10 @@ public class Island implements DataObject, MetaDataAble {
@SuppressWarnings("ConstantConditions")
public boolean inIslandSpace(Location location) {
return Util.sameWorld(this.world, location.getWorld()) &&
(location.getWorld().getEnvironment().equals(Environment.NORMAL) ||
this.getPlugin().getIWM().isIslandNether(location.getWorld()) ||
this.getPlugin().getIWM().isIslandEnd(location.getWorld())) &&
this.inIslandSpace(location.getBlockX(), location.getBlockZ());
(location.getWorld().getEnvironment().equals(Environment.NORMAL) ||
this.getPlugin().getIWM().isIslandNether(location.getWorld()) ||
this.getPlugin().getIWM().isIslandEnd(location.getWorld())) &&
this.inIslandSpace(location.getBlockX(), location.getBlockZ());
}
/**
@ -770,33 +770,33 @@ public class Island implements DataObject, MetaDataAble {
{
// Return normal world bounding box.
boundingBox = new BoundingBox(this.getMinX(),
this.world.getMinHeight(),
this.getMinZ(),
this.getMaxX(),
this.world.getMaxHeight(),
this.getMaxZ());
this.world.getMinHeight(),
this.getMinZ(),
this.getMaxX(),
this.world.getMaxHeight(),
this.getMaxZ());
}
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(),
this.getMaxX(),
this.getEndWorld().getMaxHeight(),
this.getMaxZ());
this.getEndWorld().getMinHeight(),
this.getMinZ(),
this.getMaxX(),
this.getEndWorld().getMaxHeight(),
this.getMaxZ());
}
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(),
this.getMaxX(),
this.getNetherWorld().getMaxHeight(),
this.getMaxZ());
this.getNetherWorld().getMinHeight(),
this.getMinZ(),
this.getMaxX(),
this.getNetherWorld().getMaxHeight(),
this.getMaxZ());
}
else
{
@ -913,13 +913,13 @@ public class Island implements DataObject, MetaDataAble {
@SuppressWarnings("ConstantConditions")
public boolean onIsland(@NonNull Location target) {
return Util.sameWorld(this.world, target.getWorld()) &&
(target.getWorld().getEnvironment().equals(Environment.NORMAL) ||
this.getPlugin().getIWM().isIslandNether(target.getWorld()) ||
this.getPlugin().getIWM().isIslandEnd(target.getWorld())) &&
target.getBlockX() >= this.getMinProtectedX() &&
target.getBlockX() < (this.getMinProtectedX() + this.protectionRange * 2) &&
target.getBlockZ() >= this.getMinProtectedZ() &&
target.getBlockZ() < (this.getMinProtectedZ() + this.protectionRange * 2);
(target.getWorld().getEnvironment().equals(Environment.NORMAL) ||
this.getPlugin().getIWM().isIslandNether(target.getWorld()) ||
this.getPlugin().getIWM().isIslandEnd(target.getWorld())) &&
target.getBlockX() >= this.getMinProtectedX() &&
target.getBlockX() < (this.getMinProtectedX() + this.protectionRange * 2) &&
target.getBlockZ() >= this.getMinProtectedZ() &&
target.getBlockZ() < (this.getMinProtectedZ() + this.protectionRange * 2);
}
/**
@ -950,33 +950,33 @@ public class Island implements DataObject, MetaDataAble {
{
// Return normal world bounding box.
boundingBox = new BoundingBox(this.getMinProtectedX(),
this.world.getMinHeight(),
this.getMinProtectedZ(),
this.getMaxProtectedX(),
this.world.getMaxHeight(),
this.getMaxProtectedZ());
this.world.getMinHeight(),
this.getMinProtectedZ(),
this.getMaxProtectedX(),
this.world.getMaxHeight(),
this.getMaxProtectedZ());
}
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(),
this.getMaxProtectedX(),
this.getEndWorld().getMaxHeight(),
this.getMaxProtectedZ());
this.getEndWorld().getMinHeight(),
this.getMinProtectedZ(),
this.getMaxProtectedX(),
this.getEndWorld().getMaxHeight(),
this.getMaxProtectedZ());
}
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(),
this.getMaxProtectedX(),
this.getNetherWorld().getMaxHeight(),
this.getMaxProtectedZ());
this.getNetherWorld().getMinHeight(),
this.getMinProtectedZ(),
this.getMaxProtectedX(),
this.getNetherWorld().getMaxHeight(),
this.getMaxProtectedZ());
}
else
{
@ -1057,11 +1057,11 @@ public class Island implements DataObject, MetaDataAble {
BentoBox plugin = BentoBox.getInstance();
Map<String, Integer> result = new HashMap<>();
plugin.getFlagsManager().getFlags().stream().
filter(f -> f.getType().equals(Flag.Type.PROTECTION)).
forEach(f -> result.put(f.getID(), plugin.getIWM().getDefaultIslandFlags(world).getOrDefault(f, f.getDefaultRank())));
filter(f -> f.getType().equals(Flag.Type.PROTECTION)).
forEach(f -> result.put(f.getID(), plugin.getIWM().getDefaultIslandFlags(world).getOrDefault(f, f.getDefaultRank())));
plugin.getFlagsManager().getFlags().stream().
filter(f -> f.getType().equals(Flag.Type.SETTING)).
forEach(f -> result.put(f.getID(), plugin.getIWM().getDefaultIslandSettings(world).getOrDefault(f, f.getDefaultRank())));
filter(f -> f.getType().equals(Flag.Type.SETTING)).
forEach(f -> result.put(f.getID(), plugin.getIWM().getDefaultIslandSettings(world).getOrDefault(f, f.getDefaultRank())));
this.setFlags(result);
setChanged();
}

View File

@ -1,11 +1,12 @@
package world.bentobox.bentobox.database.objects.adapters;
import org.bukkit.configuration.MemorySection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.configuration.MemorySection;
/**
* This Serializer migrates Map of String, Boolean to Map of String, Integer in serialization process.

View File

@ -1,7 +1,5 @@
package world.bentobox.bentobox.database.sql;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashSet;
@ -10,6 +8,9 @@ import java.util.Set;
import org.bukkit.Bukkit;
import org.eclipse.jdt.annotation.NonNull;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
import world.bentobox.bentobox.database.DatabaseConnector;

View File

@ -11,13 +11,14 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import javax.sql.DataSource;
import org.bukkit.Bukkit;
import org.eclipse.jdt.annotation.NonNull;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import javax.sql.DataSource;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.database.DatabaseConnector;
import world.bentobox.bentobox.database.json.AbstractJSONDatabaseHandler;

View File

@ -1,8 +1,9 @@
package world.bentobox.bentobox.database.sql.mariadb;
import com.zaxxer.hikari.HikariConfig;
import org.eclipse.jdt.annotation.NonNull;
import com.zaxxer.hikari.HikariConfig;
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
import world.bentobox.bentobox.database.sql.SQLDatabaseConnector;

View File

@ -1,8 +1,9 @@
package world.bentobox.bentobox.database.sql.mysql;
import com.zaxxer.hikari.HikariConfig;
import org.eclipse.jdt.annotation.NonNull;
import com.zaxxer.hikari.HikariConfig;
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
import world.bentobox.bentobox.database.sql.SQLDatabaseConnector;

View File

@ -1,8 +1,9 @@
package world.bentobox.bentobox.database.sql.postgresql;
import com.zaxxer.hikari.HikariConfig;
import org.eclipse.jdt.annotation.NonNull;
import com.zaxxer.hikari.HikariConfig;
import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl;
import world.bentobox.bentobox.database.sql.SQLDatabaseConnector;

View File

@ -151,9 +151,8 @@ public class YamlDatabaseConnector implements DatabaseConnector {
for (Entry<String, String> e : commentMap.entrySet()) {
if (nextLine.contains(e.getKey())) {
// We want the comment to start at the same level as the entry
String commentLine = " ".repeat(Math.max(0, nextLine.indexOf(e.getKey()))) +
nextLine = " ".repeat(Math.max(0, nextLine.indexOf(e.getKey()))) +
e.getValue();
nextLine = commentLine;
break;
}
}

View File

@ -148,7 +148,7 @@ public class PortalTeleportationListener implements Listener {
// Do nothing
}
};
}
}

View File

@ -4,7 +4,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.Material;
import org.bukkit.World;
@ -39,7 +38,7 @@ public class GeoMobLimitTab implements Tab, ClickHandler {
.filter(EntityType::isAlive)
.filter(t -> !(t.equals(EntityType.PLAYER) || t.equals(EntityType.GIANT) || t.equals(EntityType.ARMOR_STAND)))
.sorted(Comparator.comparing(EntityType::name))
.collect(Collectors.toList()));
.toList());
public enum EntityLimitTabType {
GEO_LIMIT,
@ -110,7 +109,7 @@ public class GeoMobLimitTab implements Tab, ClickHandler {
@Override
public List<@Nullable PanelItem> getPanelItems() {
// Make panel items
return LIVING_ENTITY_TYPES.stream().map(c -> getPanelItem(c, user)).collect(Collectors.toList());
return LIVING_ENTITY_TYPES.stream().map(c -> getPanelItem(c, user)).toList();
}
@Override

View File

@ -1,6 +1,5 @@
package world.bentobox.bentobox.listeners.flags.protection;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;

View File

@ -6,7 +6,6 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EnderCrystal;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;

View File

@ -2,7 +2,15 @@ package world.bentobox.bentobox.listeners.flags.protection;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.*;
import org.bukkit.entity.Allay;
import org.bukkit.entity.Animals;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Boat;
import org.bukkit.entity.ChestBoat;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.Villager;
import org.bukkit.entity.WanderingTrader;
import org.bukkit.entity.minecart.HopperMinecart;
import org.bukkit.entity.minecart.PoweredMinecart;
import org.bukkit.entity.minecart.RideableMinecart;

View File

@ -1,6 +1,5 @@
package world.bentobox.bentobox.listeners.flags.protection;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;

View File

@ -90,10 +90,7 @@ public class PlaceBlocksListener extends FlagListener
switch (e.getClickedBlock().getType())
{
case FIREWORK_ROCKET ->
{
this.checkIsland(e, e.getPlayer(), e.getClickedBlock().getLocation(), Flags.PLACE_BLOCKS);
}
case FIREWORK_ROCKET -> this.checkIsland(e, e.getPlayer(), e.getClickedBlock().getLocation(), Flags.PLACE_BLOCKS);
case RAIL, POWERED_RAIL, DETECTOR_RAIL, ACTIVATOR_RAIL ->
{
if (e.getMaterial() == Material.MINECART ||

View File

@ -3,7 +3,8 @@ package world.bentobox.bentobox.listeners.flags.settings;
import java.util.Optional;
import org.bukkit.Location;
import org.bukkit.entity.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.PufferFish;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.CreatureSpawnEvent;

View File

@ -7,11 +7,12 @@
package world.bentobox.bentobox.listeners.flags.worldsettings;
import java.util.Optional;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.raid.RaidTriggerEvent;
import java.util.Optional;
import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.api.user.User;

View File

@ -7,6 +7,13 @@
package world.bentobox.bentobox.listeners.teleports;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -14,7 +21,6 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import java.util.*;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon;

View File

@ -7,6 +7,8 @@
package world.bentobox.bentobox.listeners.teleports;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -22,8 +24,6 @@ import org.bukkit.event.entity.EntityPortalExitEvent;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.NonNull;
import java.util.UUID;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.util.Util;

View File

@ -7,6 +7,9 @@
package world.bentobox.bentobox.listeners.teleports;
import java.util.Objects;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -25,9 +28,6 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.NonNull;
import java.util.Objects;
import java.util.UUID;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.blueprints.Blueprint;
import world.bentobox.bentobox.blueprints.BlueprintPaster;
@ -55,9 +55,9 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
}
// ---------------------------------------------------------------------
// Section: Listeners
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Section: Listeners
// ---------------------------------------------------------------------
/**
@ -76,8 +76,9 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
{
switch (event.getCause())
{
case NETHER_PORTAL -> this.portalProcess(event, World.Environment.NETHER);
case END_PORTAL, END_GATEWAY -> this.portalProcess(event, World.Environment.THE_END);
case NETHER_PORTAL -> this.portalProcess(event, World.Environment.NETHER);
case END_PORTAL, END_GATEWAY -> this.portalProcess(event, World.Environment.THE_END);
default -> throw new IllegalArgumentException("Unexpected value: " + event.getCause());
}
}
@ -101,7 +102,7 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
UUID uuid = entity.getUniqueId();
if (this.inPortal.contains(uuid) ||
!this.plugin.getIWM().inWorld(Util.getWorld(event.getLocation().getWorld())))
!this.plugin.getIWM().inWorld(Util.getWorld(event.getLocation().getWorld())))
{
return;
}
@ -120,12 +121,12 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
{
// Create new PlayerPortalEvent
PlayerPortalEvent en = new PlayerPortalEvent((Player) entity,
event.getLocation(),
null,
PlayerTeleportEvent.TeleportCause.NETHER_PORTAL,
0,
false,
0);
event.getLocation(),
null,
PlayerTeleportEvent.TeleportCause.NETHER_PORTAL,
0,
false,
0);
this.portalProcess(en, World.Environment.NETHER);
}
@ -138,12 +139,12 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
{
// Create new PlayerPortalEvent
PlayerPortalEvent en = new PlayerPortalEvent((Player) entity,
event.getLocation(),
null,
type.equals(Material.END_PORTAL) ? PlayerTeleportEvent.TeleportCause.END_PORTAL : PlayerTeleportEvent.TeleportCause.END_GATEWAY,
0,
false,
0);
event.getLocation(),
null,
type.equals(Material.END_PORTAL) ? PlayerTeleportEvent.TeleportCause.END_PORTAL : PlayerTeleportEvent.TeleportCause.END_GATEWAY,
0,
false,
0);
this.portalProcess(en, World.Environment.THE_END);
}
@ -212,24 +213,24 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
event.setRespawnLocation(location);
}
},
() -> {
// Player does not an island. Try to get spawn island, and if that fails, use world spawn point.
// If spawn point is not safe, do nothing. Let server handle it.
() -> {
// Player does not an island. Try to get spawn island, and if that fails, use world spawn point.
// If spawn point is not safe, do nothing. Let server handle it.
Location spawnLocation = this.getSpawnLocation(overWorld);
Location spawnLocation = this.getSpawnLocation(overWorld);
if (spawnLocation != null)
{
event.setRespawnLocation(spawnLocation);
}
});
if (spawnLocation != null)
{
event.setRespawnLocation(spawnLocation);
}
});
}
// ---------------------------------------------------------------------
// Section: Processors
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Section: Processors
// ---------------------------------------------------------------------
/**
@ -286,7 +287,7 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
// To the nether/end or overworld.
World toWorld = !fromWorld.getEnvironment().equals(environment) ?
this.getNetherEndWorld(overWorld, environment) : overWorld;
this.getNetherEndWorld(overWorld, environment) : overWorld;
// Set whether portals should be created or not
event.setCanCreatePortal(this.isMakePortals(overWorld, environment));
@ -300,14 +301,14 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
// Find the distance from edge of island's protection and set the search radius
this.getIsland(event.getTo()).ifPresent(island ->
event.setSearchRadius(this.calculateSearchRadius(event.getTo(), island)));
event.setSearchRadius(this.calculateSearchRadius(event.getTo(), island)));
// Check if there is an island there or not
if (this.isPastingMissingIslands(overWorld) &&
this.isAllowedInConfig(overWorld, environment) &&
this.isIslandWorld(overWorld, environment) &&
this.getNetherEndWorld(overWorld, environment) != null &&
this.getIsland(event.getTo()).
this.isAllowedInConfig(overWorld, environment) &&
this.isIslandWorld(overWorld, environment) &&
this.getNetherEndWorld(overWorld, environment) != null &&
this.getIsland(event.getTo()).
filter(island -> !this.hasPartnerIsland(island, environment)).
map(island -> {
event.setCancelled(true);
@ -345,15 +346,15 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
{
// Else manually teleport entity
ClosestSafeSpotTeleport.builder(this.plugin).
entity(event.getPlayer()).
location(event.getTo()).
portal().
successRunnable(() -> {
// Reset velocity just in case.
event.getPlayer().setVelocity(new Vector(0,0,0));
event.getPlayer().setFallDistance(0);
}).
build();
entity(event.getPlayer()).
location(event.getTo()).
portal().
successRunnable(() -> {
// Reset velocity just in case.
event.getPlayer().setVelocity(new Vector(0,0,0));
event.getPlayer().setFallDistance(0);
}).
build();
}
});
}
@ -366,15 +367,15 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
* @param environment - environment involved
*/
private void handleToStandardNetherOrEnd(PlayerPortalEvent event,
World overWorld,
World.Environment environment)
World overWorld,
World.Environment environment)
{
World toWorld = Objects.requireNonNull(this.getNetherEndWorld(overWorld, environment));
Location spawnPoint = toWorld.getSpawnLocation();
// If going to the nether and nether portals are active then just teleport to approx location
if (environment.equals(World.Environment.NETHER) &&
this.plugin.getIWM().getWorldSettings(overWorld).isMakeNetherPortals())
this.plugin.getIWM().getWorldSettings(overWorld).isMakeNetherPortals())
{
spawnPoint = event.getFrom().toVector().toLocation(toWorld);
}
@ -396,10 +397,10 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
{
// Teleport to standard nether or end
ClosestSafeSpotTeleport.builder(this.plugin).
entity(event.getPlayer()).
location(spawnPoint).
portal().
build();
entity(event.getPlayer()).
location(spawnPoint).
portal().
build();
}
}
@ -413,14 +414,14 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
private void handleFromStandardNetherOrEnd(PlayerPortalEvent event, World overWorld, World.Environment environment)
{
if (environment.equals(World.Environment.NETHER) &&
this.plugin.getIWM().getWorldSettings(overWorld).isMakeNetherPortals())
this.plugin.getIWM().getWorldSettings(overWorld).isMakeNetherPortals())
{
// Set to location directly to the from location.
event.setTo(event.getFrom().toVector().toLocation(overWorld));
// Update portal search radius.
this.getIsland(event.getTo()).ifPresent(island ->
event.setSearchRadius(this.calculateSearchRadius(event.getTo(), island)));
event.setSearchRadius(this.calculateSearchRadius(event.getTo(), island)));
event.setCanCreatePortal(true);
// event.setCreationRadius(16); 16 is default creation radius.
@ -430,14 +431,14 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
// Cannot be portal. Should recalculate position.
// TODO: Currently, it is always spawn location. However, default home must be assigned.
Location toLocation = this.getIsland(overWorld, event.getPlayer()).
map(island -> island.getSpawnPoint(World.Environment.NORMAL)).
orElseGet(() -> {
// If player do not have island, try spawn.
Location spawnLocation = this.getSpawnLocation(overWorld);
return spawnLocation == null ?
event.getFrom().toVector().toLocation(overWorld) :
spawnLocation;
});
map(island -> island.getSpawnPoint(World.Environment.NORMAL)).
orElseGet(() -> {
// If player do not have island, try spawn.
Location spawnLocation = this.getSpawnLocation(overWorld);
return spawnLocation == null ?
event.getFrom().toVector().toLocation(overWorld) :
spawnLocation;
});
event.setTo(toLocation);
}
@ -449,10 +450,10 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
// Teleport to standard nether or end
ClosestSafeSpotTeleport.builder(this.plugin).
entity(event.getPlayer()).
location(event.getTo()).
portal().
build();
entity(event.getPlayer()).
location(event.getTo()).
portal().
build();
}
}
@ -465,9 +466,9 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
* @param environment - NETHER or THE_END
*/
private void pasteNewIsland(Player player,
Location to,
Island island,
World.Environment environment)
Location to,
Island island,
World.Environment environment)
{
// Paste then teleport player
this.plugin.getIWM().getAddon(island.getWorld()).ifPresent(addon ->
@ -478,13 +479,13 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
if (blueprintBundle != null)
{
Blueprint bluePrint = this.plugin.getBlueprintsManager().getBlueprints(addon).
get(blueprintBundle.getBlueprint(environment));
get(blueprintBundle.getBlueprint(environment));
if (bluePrint != null)
{
new BlueprintPaster(this.plugin, bluePrint, to.getWorld(), island).
paste().
thenAccept(state -> ClosestSafeSpotTeleport.builder(this.plugin).
paste().
thenAccept(state -> ClosestSafeSpotTeleport.builder(this.plugin).
entity(player).
location(island.getSpawnPoint(environment) == null ? to : island.getSpawnPoint(environment)).
portal().
@ -493,7 +494,7 @@ public class PlayerTeleportListener extends AbstractTeleportListener implements
else
{
this.plugin.logError("Could not paste default island in nether or end. " +
"Is there a nether-island or end-island blueprint?");
"Is there a nether-island or end-island blueprint?");
}
}
});

View File

@ -1,24 +1,73 @@
package world.bentobox.bentobox.lists;
import com.google.common.base.Enums;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import com.google.common.base.Enums;
import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.api.flags.Flag.Type;
import world.bentobox.bentobox.api.flags.clicklisteners.CycleClick;
import world.bentobox.bentobox.listeners.flags.clicklisteners.CommandRankClickListener;
import world.bentobox.bentobox.listeners.flags.clicklisteners.GeoLimitClickListener;
import world.bentobox.bentobox.listeners.flags.clicklisteners.MobLimitClickListener;
import world.bentobox.bentobox.listeners.flags.protection.*;
import world.bentobox.bentobox.listeners.flags.protection.BlockInteractionListener;
import world.bentobox.bentobox.listeners.flags.protection.BreakBlocksListener;
import world.bentobox.bentobox.listeners.flags.protection.BreedingListener;
import world.bentobox.bentobox.listeners.flags.protection.BucketListener;
import world.bentobox.bentobox.listeners.flags.protection.DyeListener;
import world.bentobox.bentobox.listeners.flags.protection.EggListener;
import world.bentobox.bentobox.listeners.flags.protection.ElytraListener;
import world.bentobox.bentobox.listeners.flags.protection.EntityInteractListener;
import world.bentobox.bentobox.listeners.flags.protection.ExperiencePickupListener;
import world.bentobox.bentobox.listeners.flags.protection.FireListener;
import world.bentobox.bentobox.listeners.flags.protection.HurtingListener;
import world.bentobox.bentobox.listeners.flags.protection.InventoryListener;
import world.bentobox.bentobox.listeners.flags.protection.ItemDropPickUpListener;
import world.bentobox.bentobox.listeners.flags.protection.LeashListener;
import world.bentobox.bentobox.listeners.flags.protection.LecternListener;
import world.bentobox.bentobox.listeners.flags.protection.LockAndBanListener;
import world.bentobox.bentobox.listeners.flags.protection.PaperExperiencePickupListener;
import world.bentobox.bentobox.listeners.flags.protection.PhysicalInteractionListener;
import world.bentobox.bentobox.listeners.flags.protection.PlaceBlocksListener;
import world.bentobox.bentobox.listeners.flags.protection.PortalListener;
import world.bentobox.bentobox.listeners.flags.protection.SculkSensorListener;
import world.bentobox.bentobox.listeners.flags.protection.SculkShriekerListener;
import world.bentobox.bentobox.listeners.flags.protection.ShearingListener;
import world.bentobox.bentobox.listeners.flags.protection.TNTListener;
import world.bentobox.bentobox.listeners.flags.protection.TeleportationListener;
import world.bentobox.bentobox.listeners.flags.protection.ThrowingListener;
import world.bentobox.bentobox.listeners.flags.settings.DecayListener;
import world.bentobox.bentobox.listeners.flags.settings.MobSpawnListener;
import world.bentobox.bentobox.listeners.flags.settings.PVPListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.*;
import world.bentobox.bentobox.listeners.flags.worldsettings.ChestDamageListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.CleanSuperFlatListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.CoarseDirtTillingListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.CreeperListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.EnderChestListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.EndermanListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.EnterExitListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.GeoLimitMobsListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.InvincibleVisitorsListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.IslandRespawnListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.ItemFrameListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.LimitMobsListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.LiquidsFlowingOutListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.NaturalSpawningOutsideRangeListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.ObsidianScoopingListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.OfflineGrowthListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.OfflineRedstoneListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.PetTeleportListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.PistonPushListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.RemoveMobsListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.SpawnerSpawnEggsListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.TreesGrowingOutsideRangeListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.VisitorKeepInventoryListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.VisitorsStartingRaidListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.WitherListener;
import world.bentobox.bentobox.managers.RanksManager;
import world.bentobox.bentobox.util.Util;
@ -592,6 +641,6 @@ public final class Flags {
Bukkit.getLogger().severe("Could not get Flag values " + e.getMessage());
}
return null;
}).collect(Collectors.toList());
}).toList();
}
}

View File

@ -22,7 +22,6 @@ import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
@ -477,7 +476,7 @@ public class AddonsManager {
return getEnabledAddons().stream()
.filter(GameModeAddon.class::isInstance)
.map(GameModeAddon.class::cast)
.collect(Collectors.toList());
.toList();
}
/**
@ -487,7 +486,7 @@ public class AddonsManager {
*/
@NonNull
public List<Addon> getLoadedAddons() {
return addons.stream().filter(addon -> addon.getState().equals(Addon.State.LOADED)).collect(Collectors.toList());
return addons.stream().filter(addon -> addon.getState().equals(Addon.State.LOADED)).toList();
}
/**
@ -497,7 +496,7 @@ public class AddonsManager {
*/
@NonNull
public List<Addon> getEnabledAddons() {
return addons.stream().filter(addon -> addon.getState().equals(Addon.State.ENABLED)).collect(Collectors.toList());
return addons.stream().filter(addon -> addon.getState().equals(Addon.State.ENABLED)).toList();
}
@Nullable
@ -535,7 +534,7 @@ public class AddonsManager {
*/
private void sortAddons() {
// Lists all available addons as names.
List<String> names = addons.stream().map(a -> a.getDescription().getName()).collect(Collectors.toList());
List<String> names = addons.stream().map(a -> a.getDescription().getName()).toList();
// Check that any dependencies exist
Iterator<Addon> addonsIterator = addons.iterator();
@ -556,7 +555,7 @@ public class AddonsManager {
addons.stream().filter(a -> a.getDescription().getDependencies().isEmpty() && a.getDescription().getSoftDependencies().isEmpty())
.forEach(a -> sortedAddons.put(a.getDescription().getName(), a));
// Fill remaining
List<Addon> remaining = addons.stream().filter(a -> !sortedAddons.containsKey(a.getDescription().getName())).collect(Collectors.toList());
List<Addon> remaining = addons.stream().filter(a -> !sortedAddons.containsKey(a.getDescription().getName())).toList();
// Run through remaining addons
remaining.forEach(addon -> {
@ -587,7 +586,7 @@ public class AddonsManager {
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
// Clean up world name
String w = worldName.replace("_nether", "").replace("_the_end", "").toLowerCase(Locale.ENGLISH);
if (worldNames.containsKey(w)) {
if (worldNames.containsKey(w) && worldNames.get(w) != null) {
return worldNames.get(w).getDefaultWorldGenerator(worldName, id);
}
return null;
@ -658,7 +657,7 @@ public class AddonsManager {
.filter(DataObject.class::isAssignableFrom)
// Do not include config files
.filter(c -> !ConfigObject.class.isAssignableFrom(c))
.collect(Collectors.toList());
.toList();
}
/**

View File

@ -1,11 +1,24 @@
package world.bentobox.bentobox.managers;
import java.io.*;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.JarFile;

View File

@ -71,8 +71,7 @@ public class IslandWorldManager {
private void registerToWorldManagementPlugins(@NonNull World world, boolean islandWorld) {
if (plugin.getHooks() != null) {
for (Hook hook : plugin.getHooks().getHooks()) {
if (hook instanceof WorldManagementHook) {
final WorldManagementHook worldManagementHook = (WorldManagementHook) hook;
if (hook instanceof final WorldManagementHook worldManagementHook) {
if (Bukkit.isPrimaryThread()) {
worldManagementHook.registerWorld(world, islandWorld);
} else {
@ -119,7 +118,7 @@ public class IslandWorldManager {
*/
public List<World> getOverWorlds() {
return gameModes.keySet().stream().filter(w -> w.getEnvironment().equals(Environment.NORMAL))
.collect(Collectors.toList());
.toList();
}
/**

View File

@ -1700,7 +1700,7 @@ public class IslandsManager {
@NonNull
public List<Island> getQuarantinedIslandByUser(@NonNull World world, @Nullable UUID uuid) {
return quarantineCache.getOrDefault(uuid, Collections.emptyList()).stream()
.filter(i -> i.getWorld().equals(world)).collect(Collectors.toList());
.filter(i -> i.getWorld().equals(world)).toList();
}
/**

View File

@ -8,7 +8,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
@ -18,9 +17,9 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import io.github.thebusybiscuit.githubjavaapi.GitHubWebAPI;
import io.github.thebusybiscuit.githubjavaapi.objects.repositories.GitHubContributor;
import io.github.thebusybiscuit.githubjavaapi.objects.repositories.GitHubRepository;
import io.github.TheBusyBiscuit.GitHubWebAPI4Java.GitHubWebAPI;
import io.github.TheBusyBiscuit.GitHubWebAPI4Java.objects.repositories.GitHubContributor;
import io.github.TheBusyBiscuit.GitHubWebAPI4Java.objects.repositories.GitHubRepository;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.web.catalog.CatalogEntry;
@ -103,7 +102,7 @@ public class WebManager {
repositories.addAll(plugin.getAddonsManager().getEnabledAddons()
.stream().map(addon -> addon.getDescription().getRepository())
.filter(repo -> !repo.isEmpty())
.collect(Collectors.toList()));
.toList());
/* Download the contributors */
if (plugin.getSettings().isLogGithubDownloadData()) {

View File

@ -192,14 +192,9 @@ public class NewIsland {
event = event.getNewEvent().orElse(event);
// Get the new BlueprintBundle if it was changed
switch (reason) {
case CREATE:
name = ((IslandCreateEvent) event).getBlueprintBundle().getUniqueId();
break;
case RESET:
name = ((IslandResetEvent) event).getBlueprintBundle().getUniqueId();
break;
default:
break;
case CREATE -> name = ((IslandCreateEvent) event).getBlueprintBundle().getUniqueId();
case RESET -> name = ((IslandResetEvent) event).getBlueprintBundle().getUniqueId();
default -> {}
}
// Run task to run after creating the island in one tick if island is not being pasted
@ -318,14 +313,10 @@ public class NewIsland {
// Fire exit event
Reason reasonDone = Reason.CREATED;
switch (reason) {
case CREATE:
reasonDone = Reason.CREATED;
break;
case RESET:
reasonDone = Reason.RESETTED;
break;
default:
break;
case CREATE -> reasonDone = Reason.CREATED;
case RESET -> reasonDone = Reason.RESETTED;
default -> {
}
}
IslandEvent.builder()
.involvedPlayer(user.getUniqueId())

View File

@ -1,15 +1,16 @@
package world.bentobox.bentobox.nms;
import org.bukkit.Location;
import org.bukkit.World;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity;
import world.bentobox.bentobox.database.objects.Island;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import org.bukkit.Location;
import org.bukkit.World;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity;
import world.bentobox.bentobox.database.objects.Island;
/**
* A helper class for {@link world.bentobox.bentobox.blueprints.BlueprintPaster}
*/

View File

@ -1,6 +1,11 @@
package world.bentobox.bentobox.nms;
import io.papermc.lib.PaperLib;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
@ -10,17 +15,13 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.BoundingBox;
import io.papermc.lib.PaperLib;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.database.objects.IslandDeletion;
import world.bentobox.bentobox.util.MyBiomeGrid;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
public abstract class SimpleWorldRegenerator implements WorldRegenerator {
private final BentoBox plugin;

View File

@ -1,11 +1,12 @@
package world.bentobox.bentobox.nms;
import java.util.concurrent.CompletableFuture;
import org.bukkit.World;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.database.objects.IslandDeletion;
import java.util.concurrent.CompletableFuture;
/**
* A world generator used by {@link world.bentobox.bentobox.util.DeleteIslandChunks}
*/

View File

@ -1,18 +1,19 @@
package world.bentobox.bentobox.nms.fallback;
import org.bukkit.Location;
import org.bukkit.World;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.nms.PasteHandler;
import world.bentobox.bentobox.util.DefaultPasteUtil;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import org.bukkit.Location;
import org.bukkit.World;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.nms.PasteHandler;
import world.bentobox.bentobox.util.DefaultPasteUtil;
public class PasteHandlerImpl implements PasteHandler {
@Override
public CompletableFuture<Void> pasteBlocks(Island island, World world, Map<Location, BlueprintBlock> blockMap) {

View File

@ -2,6 +2,7 @@ package world.bentobox.bentobox.panels;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@ -241,7 +242,7 @@ public class BlueprintManagementPanel {
protected PanelItem getBundleIcon(BlueprintBundle bb) {
return new PanelItemBuilder()
.name(t("edit-description"))
.description(bb.getDescription().stream().map(Util::translateColorCodes).collect(Collectors.toList()))
.description(bb.getDescription().stream().map(Util::translateColorCodes).toList())
.icon(bb.getIcon())
.clickHandler((panel, u, clickType, slot) -> {
u.closeInventory();
@ -339,7 +340,7 @@ public class BlueprintManagementPanel {
protected PanelItem getBlueprintItem(GameModeAddon addon, int pos, BlueprintBundle bb, Blueprint blueprint) {
// Create description
List<String> desc = blueprint.getDescription() == null ? new ArrayList<>() : blueprint.getDescription();
desc = desc.stream().map(Util::translateColorCodes).collect(Collectors.toList());
desc = desc.stream().map(Util::translateColorCodes).collect(Collectors.toList()); // Must be mutable
if ((!blueprint.equals(endBlueprint) && !blueprint.equals(normalBlueprint) && !blueprint.equals(netherBlueprint))) {
if ((pos > MIN_WORLD_SLOT && pos < MAX_WORLD_SLOT)) {
desc.add(t("remove"));

View File

@ -3,7 +3,6 @@ package world.bentobox.bentobox.panels;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
@ -40,7 +39,7 @@ public class IslandCreationPanel {
// Get the bundles
Comparator<BlueprintBundle> sortByDisplayName = (p, o) -> p.getDisplayName().compareToIgnoreCase(o.getDisplayName());
List<BlueprintBundle> bbs = plugin.getBlueprintsManager().getBlueprintBundles(command.getAddon()).values()
.stream().sorted(sortByDisplayName).collect(Collectors.toList());
.stream().sorted(sortByDisplayName).toList();
// Loop through them and create items in the panel
for (BlueprintBundle bb : bbs) {
String perm = command.getPermissionPrefix() + "island.create." + bb.getUniqueId();
@ -50,7 +49,7 @@ public class IslandCreationPanel {
// Add an item
PanelItem item = new PanelItemBuilder()
.name(bb.getDisplayName())
.description(bb.getDescription().stream().map(Util::translateColorCodes).collect(Collectors.toList()))
.description(bb.getDescription().stream().map(Util::translateColorCodes).toList())
.icon(bb.getIcon()).clickHandler((panel, user1, clickType, slot1) -> {
user1.closeInventory();
command.execute(user1, label, Collections.singletonList(bb.getUniqueId()));

View File

@ -1,7 +1,6 @@
package world.bentobox.bentobox.panels;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -91,7 +90,7 @@ public class ManagementPanel {
}
}
case ADDONS -> {
addons = plugin.getAddonsManager().getEnabledAddons().stream().filter(addon -> !(addon instanceof GameModeAddon)).collect(Collectors.toList());
addons = plugin.getAddonsManager().getEnabledAddons().stream().filter(addon -> !(addon instanceof GameModeAddon)).toList();
if (addons.isEmpty()) {
looksEmpty(builder, user);
break;

View File

@ -4,7 +4,6 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -78,7 +77,7 @@ public class SettingsTab implements Tab, ClickHandler {
List<Flag> flags = plugin.getFlagsManager().getFlags().stream().filter(f -> f.getType().equals(type))
// We're stripping colors to avoid weird sorting issues
.sorted(Comparator.comparing(flag -> ChatColor.stripColor(user.getTranslation(flag.getNameReference()))))
.collect(Collectors.toList());
.toList();
// Remove any that are not for this game mode
plugin.getIWM().getAddon(world).ifPresent(gm -> flags.removeIf(f -> !f.getGameModes().isEmpty() && !f.getGameModes().contains(gm)));
// Remove any that are the wrong rank or that will be on the top row
@ -124,7 +123,7 @@ public class SettingsTab implements Tab, ClickHandler {
plugin.getPlayers().setFlagsDisplayMode(user.getUniqueId(), plugin.getPlayers().getFlagsDisplayMode(user.getUniqueId()).getNext());
flags = getFlags();
}
return flags.stream().map((f -> f.toPanelItem(plugin, user, island, plugin.getIWM().getHiddenFlags(world).contains(f.getID())))).collect(Collectors.toList());
return flags.stream().map((f -> f.toPanelItem(plugin, user, island, plugin.getIWM().getHiddenFlags(world).contains(f.getID())))).toList();
}
@Override

View File

@ -2,7 +2,6 @@ package world.bentobox.bentobox.panels.settings;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.Material;
import org.bukkit.World;
@ -82,7 +81,7 @@ public class WorldDefaultSettingsTab extends SettingsTab implements Tab {
TextVariables.DESCRIPTION, user.getTranslation(f.getDescriptionReference()),
"[setting]", worldSetting).split("\n")));
return i;
}).collect(Collectors.toList());
}).toList();
}
}

View File

@ -1,16 +1,29 @@
package world.bentobox.bentobox.util;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.*;
import org.bukkit.block.Banner;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
@ -20,9 +33,6 @@ import world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.nms.PasteHandler;
import java.util.*;
import java.util.concurrent.CompletableFuture;
/**
* A utility class for {@link PasteHandler}
*

View File

@ -1,7 +1,11 @@
package world.bentobox.bentobox.util;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitRunnable;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.events.island.IslandEvent;
@ -9,9 +13,6 @@ import world.bentobox.bentobox.api.events.island.IslandEvent.Reason;
import world.bentobox.bentobox.database.objects.IslandDeletion;
import world.bentobox.bentobox.nms.WorldRegenerator;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Deletes islands chunk by chunk
*

View File

@ -2,13 +2,16 @@ package world.bentobox.bentobox.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
@ -21,7 +24,20 @@ import org.bukkit.World.Environment;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.*;
import org.bukkit.entity.Allay;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Bat;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Flying;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.PufferFish;
import org.bukkit.entity.Shulker;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Snowman;
import org.bukkit.entity.WaterMob;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.NonNull;
@ -171,10 +187,10 @@ public class Util {
public static List<String> getOnlinePlayerList(User user) {
if (user == null || !user.isPlayer()) {
// Console and null get to see every player
return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
return Bukkit.getOnlinePlayers().stream().map(Player::getName).toList();
}
// Otherwise prevent invisible players from seeing
return Bukkit.getOnlinePlayers().stream().filter(p -> user.getPlayer().canSee(p)).map(Player::getName).collect(Collectors.toList());
return Bukkit.getOnlinePlayers().stream().filter(p -> user.getPlayer().canSee(p)).map(Player::getName).toList();
}
/**

View File

@ -7,6 +7,16 @@
package world.bentobox.bentobox.util.teleport;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
@ -21,15 +31,6 @@ import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.Nullable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.user.User;

View File

@ -22,7 +22,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -388,7 +387,7 @@ public class IslandBanCommandTest {
args.add("d");
result = ibc.tabComplete(user, "", args);
assertTrue(result.isPresent());
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
List<String> r = result.get().stream().sorted().toList();
// Compare the expected with the actual
String[] expectedName = {"dave"};
assertTrue(Arrays.equals(expectedName, r.toArray()));
@ -398,7 +397,7 @@ public class IslandBanCommandTest {
args.add("fr");
result = ibc.tabComplete(user, "", args);
assertTrue(result.isPresent());
r = result.get().stream().sorted().collect(Collectors.toList());
r = result.get().stream().sorted().toList();
// Compare the expected with the actual
String[] expected = {"frank", "freddy"};
assertTrue(Arrays.equals(expected, r.toArray()));

View File

@ -18,7 +18,6 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -472,7 +471,7 @@ public class IslandTeamKickCommandTest {
// Get the tab-complete list with no argument
Optional<List<String>> result = ibc.tabComplete(user, "", new LinkedList<>());
assertTrue(result.isPresent());
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
List<String> r = result.get().stream().sorted().toList();
// Compare the expected with the actual - first names in the list
String[] expectedNames = {"adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george"};
int i = 0;
@ -515,7 +514,7 @@ public class IslandTeamKickCommandTest {
// Get the tab-complete list with argument
Optional<List<String>> result = ibc.tabComplete(user, "", Collections.singletonList("g"));
assertTrue(result.isPresent());
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
List<String> r = result.get().stream().sorted().toList();
assertFalse(r.isEmpty());
// Compare the expected with the actual
String[] expectedNames = {"george"};

View File

@ -18,7 +18,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -282,7 +281,7 @@ public class IslandTeamUncoopCommandTest {
// Get the tab-complete list with no argument
Optional<List<String>> result = ibc.tabComplete(user, "", new LinkedList<>());
assertTrue(result.isPresent());
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
List<String> r = result.get().stream().sorted().toList();
// Compare the expected with the actual
String[] expectedNames = {"adam", "ben", "cara"};
@ -319,7 +318,7 @@ public class IslandTeamUncoopCommandTest {
args.add("c");
Optional<List<String>> result = ibc.tabComplete(user, "", args);
assertTrue(result.isPresent());
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
List<String> r = result.get().stream().sorted().toList();
// Compare the expected with the actual
String[] expectedNames = {"cara"};

View File

@ -17,7 +17,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -281,7 +280,7 @@ public class IslandTeamUntrustCommandTest {
// Get the tab-complete list with no argument
Optional<List<String>> result = ibc.tabComplete(user, "", new LinkedList<>());
assertTrue(result.isPresent());
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
List<String> r = result.get().stream().sorted().toList();
// Compare the expected with the actual
String[] expectedNames = {"adam", "ben", "cara"};
@ -317,7 +316,7 @@ public class IslandTeamUntrustCommandTest {
args.add("c");
Optional<List<String>> result = ibc.tabComplete(user, "", args);
assertTrue(result.isPresent());
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
List<String> r = result.get().stream().sorted().toList();
// Compare the expected with the actual
String[] expectedNames = {"cara"};

View File

@ -24,7 +24,6 @@ import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.NonNull;
import org.junit.After;
import org.junit.Before;

View File

@ -19,7 +19,12 @@ import java.util.Map;
import java.util.Optional;
import java.util.logging.Logger;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.Tag;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Entity;

View File

@ -13,7 +13,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@ -59,9 +58,9 @@ public class CoarseDirtTillingListenerTest {
@SuppressWarnings("deprecation")
private static final List<Material> HOES = Collections.unmodifiableList(Arrays.stream(Material.values())
.filter(m -> !m.isLegacy()).filter(m -> m.name().endsWith("_HOE")).collect(Collectors.toList()));
.filter(m -> !m.isLegacy()).filter(m -> m.name().endsWith("_HOE")).toList());
private static final List<Material> NOT_HOES = Collections.unmodifiableList(Arrays.stream(Material.values())
.filter(m -> !m.name().endsWith("_HOE")).collect(Collectors.toList()));
.filter(m -> !m.name().endsWith("_HOE")).toList());
// Class under test
private CoarseDirtTillingListener ctl;

View File

@ -21,7 +21,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@ -109,7 +108,7 @@ public class InvincibleVisitorsListenerTest {
when(panel.getName()).thenReturn("panel");
Map<Integer, PanelItem> map = new HashMap<>();
List<String> sortedNames = Arrays.stream(EntityDamageEvent.DamageCause.values()).map(DamageCause::name)
.map(Util::prettifyText).sorted().collect(Collectors.toList());
.map(Util::prettifyText).sorted().toList();
int i = 0;
for (String name : sortedNames) {
PanelItem pi = mock(PanelItem.class);
@ -220,7 +219,7 @@ public class InvincibleVisitorsListenerTest {
// Test all damage causes to make sure they can be clicked on and off
for (int slot = 0; slot < DamageCause.values().length; slot++) {
// Get the damage type
DamageCause dc = Arrays.stream(EntityDamageEvent.DamageCause.values()).sorted(Comparator.comparing(DamageCause::name)).collect(Collectors.toList()).get(slot);
DamageCause dc = Arrays.stream(EntityDamageEvent.DamageCause.values()).sorted(Comparator.comparing(DamageCause::name)).toList().get(slot);
// IV settings should be empty
assertFalse(ivSettings.contains(dc.name()));
// Click on the icon

View File

@ -1,6 +1,7 @@
package world.bentobox.bentobox.util;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;