mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-10 01:11:29 +01:00
Remove unused imports
This commit is contained in:
parent
e2fd5555cf
commit
d7b428fc58
@ -3,7 +3,6 @@ package world.bentobox.bentobox.listeners;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -15,7 +14,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
@ -57,32 +55,32 @@ public class JoinLeaveListener implements Listener {
|
||||
players.addPlayer(playerUUID);
|
||||
|
||||
plugin.getIWM().getOverWorlds().stream()
|
||||
.filter(w -> plugin.getIWM().isCreateIslandOnFirstLoginEnabled(w))
|
||||
.forEach(w -> {
|
||||
// Even if that'd be extremely unlikely, it's better to check if the player doesn't have an already.
|
||||
if (!(plugin.getIslands().hasIsland(w, user) || plugin.getIslands().inTeam(w, user.getUniqueId()))) {
|
||||
int delay = plugin.getIWM().getCreateIslandOnFirstLoginDelay(w);
|
||||
user.sendMessage("commands.island.create.on-first-login",
|
||||
TextVariables.NUMBER, String.valueOf(delay));
|
||||
.filter(w -> plugin.getIWM().isCreateIslandOnFirstLoginEnabled(w))
|
||||
.forEach(w -> {
|
||||
// Even if that'd be extremely unlikely, it's better to check if the player doesn't have an already.
|
||||
if (!(plugin.getIslands().hasIsland(w, user) || plugin.getIslands().inTeam(w, user.getUniqueId()))) {
|
||||
int delay = plugin.getIWM().getCreateIslandOnFirstLoginDelay(w);
|
||||
user.sendMessage("commands.island.create.on-first-login",
|
||||
TextVariables.NUMBER, String.valueOf(delay));
|
||||
|
||||
Runnable createIsland = () -> {
|
||||
// should only execute if:
|
||||
// - abort on logout is false
|
||||
// - abort on logout is true && user is online
|
||||
if (!plugin.getIWM().isCreateIslandOnFirstLoginAbortOnLogout(w) || user.isOnline()){
|
||||
plugin.getIWM().getAddon(w).ifPresent(addon -> addon.getPlayerCommand()
|
||||
.map(command -> command.getSubCommand("create").orElse(null))
|
||||
.ifPresent(command -> command.execute(user, "create", Collections.singletonList(BlueprintsManager.DEFAULT_BUNDLE_NAME))));
|
||||
}
|
||||
};
|
||||
|
||||
if (delay <= 0) {
|
||||
createIsland.run();
|
||||
} else {
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, createIsland, delay * 20L);
|
||||
}
|
||||
Runnable createIsland = () -> {
|
||||
// should only execute if:
|
||||
// - abort on logout is false
|
||||
// - abort on logout is true && user is online
|
||||
if (!plugin.getIWM().isCreateIslandOnFirstLoginAbortOnLogout(w) || user.isOnline()){
|
||||
plugin.getIWM().getAddon(w).ifPresent(addon -> addon.getPlayerCommand()
|
||||
.map(command -> command.getSubCommand("create").orElse(null))
|
||||
.ifPresent(command -> command.execute(user, "create", Collections.singletonList(BlueprintsManager.DEFAULT_BUNDLE_NAME))));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (delay <= 0) {
|
||||
createIsland.run();
|
||||
} else {
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, createIsland, delay * 20L);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure the player is loaded into the cache (doesn't impact performance)
|
||||
@ -90,8 +88,8 @@ public class JoinLeaveListener implements Listener {
|
||||
|
||||
// Reset island resets if required
|
||||
plugin.getIWM().getOverWorlds().stream()
|
||||
.filter(w -> event.getPlayer().getLastPlayed() < plugin.getIWM().getResetEpoch(w))
|
||||
.forEach(w -> players.setResets(w, playerUUID, 0));
|
||||
.filter(w -> event.getPlayer().getLastPlayed() < plugin.getIWM().getResetEpoch(w))
|
||||
.forEach(w -> players.setResets(w, playerUUID, 0));
|
||||
|
||||
// Automated island ownership transfer
|
||||
if (plugin.getSettings().isEnableAutoOwnershipTransfer()) {
|
||||
@ -157,53 +155,53 @@ public class JoinLeaveListener implements Listener {
|
||||
|
||||
private void runAutomatedOwnershipTransfer(User user) {
|
||||
plugin.getIWM().getOverWorlds().stream()
|
||||
.filter(world -> plugin.getIslands().hasIsland(world, user) && !plugin.getIslands().isOwner(world, user.getUniqueId()))
|
||||
.forEach(world -> {
|
||||
Island island = plugin.getIslands().getIsland(world, user);
|
||||
.filter(world -> plugin.getIslands().hasIsland(world, user) && !plugin.getIslands().isOwner(world, user.getUniqueId()))
|
||||
.forEach(world -> {
|
||||
Island island = plugin.getIslands().getIsland(world, user);
|
||||
|
||||
OfflinePlayer owner = Bukkit.getOfflinePlayer(island.getOwner());
|
||||
OfflinePlayer owner = Bukkit.getOfflinePlayer(island.getOwner());
|
||||
|
||||
// Converting the setting (in days) to milliseconds.
|
||||
long inactivityThreshold = plugin.getSettings().getAutoOwnershipTransferInactivityThreshold() * 24 * 60 * 60 * 1000L;
|
||||
long timestamp = System.currentTimeMillis() - inactivityThreshold;
|
||||
// Converting the setting (in days) to milliseconds.
|
||||
long inactivityThreshold = plugin.getSettings().getAutoOwnershipTransferInactivityThreshold() * 24 * 60 * 60 * 1000L;
|
||||
long timestamp = System.currentTimeMillis() - inactivityThreshold;
|
||||
|
||||
// We make sure the current owner is inactive.
|
||||
if (owner.getLastPlayed() != 0 && owner.getLastPlayed() < timestamp) {
|
||||
// The current owner is inactive
|
||||
// Now, let's run through all of the island members (except the player who's just joined) and see who's active.
|
||||
// Sadly, this will make us calculate the owner inactivity again... :(
|
||||
List<UUID> candidates = Arrays.asList((UUID[]) island.getMemberSet().stream()
|
||||
.filter(uuid -> !user.getUniqueId().equals(uuid))
|
||||
.filter(uuid -> Bukkit.getOfflinePlayer(uuid).getLastPlayed() != 0
|
||||
&& Bukkit.getOfflinePlayer(uuid).getLastPlayed() < timestamp)
|
||||
.toArray());
|
||||
// We make sure the current owner is inactive.
|
||||
if (owner.getLastPlayed() != 0 && owner.getLastPlayed() < timestamp) {
|
||||
// The current owner is inactive
|
||||
// Now, let's run through all of the island members (except the player who's just joined) and see who's active.
|
||||
// Sadly, this will make us calculate the owner inactivity again... :(
|
||||
List<UUID> candidates = Arrays.asList((UUID[]) island.getMemberSet().stream()
|
||||
.filter(uuid -> !user.getUniqueId().equals(uuid))
|
||||
.filter(uuid -> Bukkit.getOfflinePlayer(uuid).getLastPlayed() != 0
|
||||
&& Bukkit.getOfflinePlayer(uuid).getLastPlayed() < timestamp)
|
||||
.toArray());
|
||||
|
||||
if (!candidates.isEmpty() && !plugin.getSettings().isAutoOwnershipTransferIgnoreRanks()) {
|
||||
// Ranks are not ignored, our candidates can only have the highest rank
|
||||
// TODO Complete this section
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!candidates.isEmpty() && !plugin.getSettings().isAutoOwnershipTransferIgnoreRanks()) {
|
||||
// Ranks are not ignored, our candidates can only have the highest rank
|
||||
// TODO Complete this section
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateIslandRange(User user) {
|
||||
plugin.getIWM().getOverWorlds().stream()
|
||||
.filter(world -> plugin.getIslands().isOwner(world, user.getUniqueId()))
|
||||
.forEach(world -> {
|
||||
Island island = plugin.getIslands().getIsland(world, user);
|
||||
if (island != null) {
|
||||
// Check if new owner has a different range permission than the island size
|
||||
int range = user.getPermissionValue(plugin.getIWM().getAddon(island.getWorld()).map(GameModeAddon::getPermissionPrefix).orElse("") + "island.range", island.getProtectionRange());
|
||||
.filter(world -> plugin.getIslands().isOwner(world, user.getUniqueId()))
|
||||
.forEach(world -> {
|
||||
Island island = plugin.getIslands().getIsland(world, user);
|
||||
if (island != null) {
|
||||
// Check if new owner has a different range permission than the island size
|
||||
int range = user.getPermissionValue(plugin.getIWM().getAddon(island.getWorld()).map(GameModeAddon::getPermissionPrefix).orElse("") + "island.range", island.getProtectionRange());
|
||||
|
||||
// Range can go up or down
|
||||
if (range != island.getProtectionRange()) {
|
||||
user.sendMessage("commands.admin.setrange.range-updated", TextVariables.NUMBER, String.valueOf(range));
|
||||
plugin.log("Island protection range changed from " + island.getProtectionRange() + " to "
|
||||
+ range + " for " + user.getName() + " due to permission.");
|
||||
}
|
||||
island.setProtectionRange(range);
|
||||
}
|
||||
});
|
||||
// Range can go up or down
|
||||
if (range != island.getProtectionRange()) {
|
||||
user.sendMessage("commands.admin.setrange.range-updated", TextVariables.NUMBER, String.valueOf(range));
|
||||
plugin.log("Island protection range changed from " + island.getProtectionRange() + " to "
|
||||
+ range + " for " + user.getName() + " due to permission.");
|
||||
}
|
||||
island.setProtectionRange(range);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@ -218,9 +216,9 @@ public class JoinLeaveListener implements Listener {
|
||||
// No, there are no more players online on this island
|
||||
// Tell players they are being removed
|
||||
island.getMembers().entrySet().stream()
|
||||
.filter(e -> e.getValue() == RanksManager.COOP_RANK)
|
||||
.forEach(e -> User.getInstance(e.getKey())
|
||||
.sendMessage("commands.island.team.uncoop.all-members-logged-off", TextVariables.NAME, plugin.getPlayers().getName(island.getOwner())));
|
||||
.filter(e -> e.getValue() == RanksManager.COOP_RANK)
|
||||
.forEach(e -> User.getInstance(e.getKey())
|
||||
.sendMessage("commands.island.team.uncoop.all-members-logged-off", TextVariables.NAME, plugin.getPlayers().getName(island.getOwner())));
|
||||
// Remove any coop players on this island
|
||||
island.removeRank(RanksManager.COOP_RANK);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.ChatColor;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||
|
Loading…
Reference in New Issue
Block a user