mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-03 05:51:43 +01:00
Improved user feedback when pasting (creation/reset) an island
Implements https://github.com/BentoBoxWorld/BentoBox/issues/996
This commit is contained in:
parent
ba35d7c062
commit
8692685822
@ -64,7 +64,7 @@ public class IslandCreateCommand extends CompositeCommand {
|
|||||||
public boolean execute(User user, String label, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// Permission check if the name is not the default one
|
// Permission check if the name is not the default one
|
||||||
if (!args.isEmpty()) {
|
if (!args.isEmpty()) {
|
||||||
String name = getPlugin().getBlueprintsManager().validate((GameModeAddon)getAddon(), args.get(0).toLowerCase(java.util.Locale.ENGLISH));
|
String name = getPlugin().getBlueprintsManager().validate(getAddon(), args.get(0).toLowerCase(java.util.Locale.ENGLISH));
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
// The blueprint name is not valid.
|
// The blueprint name is not valid.
|
||||||
user.sendMessage("commands.island.create.unknown-blueprint");
|
user.sendMessage("commands.island.create.unknown-blueprint");
|
||||||
@ -77,7 +77,7 @@ public class IslandCreateCommand extends CompositeCommand {
|
|||||||
return makeIsland(user, name);
|
return makeIsland(user, name);
|
||||||
} else {
|
} else {
|
||||||
// Show panel only if there are multiple bundles available
|
// Show panel only if there are multiple bundles available
|
||||||
if (getPlugin().getBlueprintsManager().getBlueprintBundles((GameModeAddon)getAddon()).size() > 1) {
|
if (getPlugin().getBlueprintsManager().getBlueprintBundles(getAddon()).size() > 1) {
|
||||||
// Show panel
|
// Show panel
|
||||||
IslandCreationPanel.openPanel(this, user, label);
|
IslandCreationPanel.openPanel(this, user, label);
|
||||||
return true;
|
return true;
|
||||||
@ -91,7 +91,7 @@ public class IslandCreateCommand extends CompositeCommand {
|
|||||||
try {
|
try {
|
||||||
NewIsland.builder()
|
NewIsland.builder()
|
||||||
.player(user)
|
.player(user)
|
||||||
.addon((GameModeAddon)getAddon())
|
.addon(getAddon())
|
||||||
.reason(Reason.CREATE)
|
.reason(Reason.CREATE)
|
||||||
.name(name)
|
.name(name)
|
||||||
.build();
|
.build();
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package world.bentobox.bentobox.blueprints;
|
package world.bentobox.bentobox.blueprints;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -149,6 +152,20 @@ public class BlueprintPaster {
|
|||||||
pasteState = PasteState.BLOCKS;
|
pasteState = PasteState.BLOCKS;
|
||||||
final int pasteSpeed = plugin.getSettings().getPasteSpeed();
|
final int pasteSpeed = plugin.getSettings().getPasteSpeed();
|
||||||
|
|
||||||
|
// If this is an island OVERWORLD paste, get the island owner.
|
||||||
|
final Optional<User> owner = Optional.ofNullable(island)
|
||||||
|
.filter(i -> location.getWorld().getEnvironment().equals(World.Environment.NORMAL))
|
||||||
|
.map(i -> User.getInstance(i.getOwner()));
|
||||||
|
// Tell the owner we're pasting blocks and how much time it might take
|
||||||
|
owner.ifPresent(user -> {
|
||||||
|
// Estimated time:
|
||||||
|
double total = blocks.size() + attached.size() + entities.size();
|
||||||
|
BigDecimal time = new BigDecimal(total / (pasteSpeed * 20.0D)).setScale(1, RoundingMode.UP);
|
||||||
|
user.sendMessage("commands.island.create.pasting.estimated-time", TextVariables.NUMBER, String.valueOf(time.doubleValue()));
|
||||||
|
// We're pasting blocks!
|
||||||
|
user.sendMessage("commands.island.create.pasting.blocks", TextVariables.NUMBER, String.valueOf(blocks.size() + attached.size()));
|
||||||
|
});
|
||||||
|
|
||||||
pastingTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
pastingTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (pasteState.equals(PasteState.BLOCKS) && count < pasteSpeed && it.hasNext()) {
|
while (pasteState.equals(PasteState.BLOCKS) && count < pasteSpeed && it.hasNext()) {
|
||||||
@ -169,14 +186,18 @@ public class BlueprintPaster {
|
|||||||
// Next paste attachments
|
// Next paste attachments
|
||||||
pasteState = PasteState.ATTACHMENTS;
|
pasteState = PasteState.ATTACHMENTS;
|
||||||
}
|
}
|
||||||
if (pasteState.equals(PasteState.ATTACHMENTS) && !it2.hasNext()) {
|
else if (pasteState.equals(PasteState.ATTACHMENTS) && !it2.hasNext()) {
|
||||||
// Attachments done. Next paste entities
|
// Attachments done. Next paste entities
|
||||||
pasteState = PasteState.ENTITIES;
|
pasteState = PasteState.ENTITIES;
|
||||||
|
if (entities.size() != 0) {
|
||||||
|
owner.ifPresent(user -> user.sendMessage("commands.island.create.pasting.entities", TextVariables.NUMBER, String.valueOf(entities.size())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (pasteState.equals(PasteState.ENTITIES) && !it3.hasNext()) {
|
else if (pasteState.equals(PasteState.ENTITIES) && !it3.hasNext()) {
|
||||||
pasteState = PasteState.DONE;
|
pasteState = PasteState.DONE;
|
||||||
|
owner.ifPresent(user -> user.sendMessage("commands.island.create.pasting.done"));
|
||||||
}
|
}
|
||||||
if (pasteState.equals(PasteState.DONE)) {
|
else if (pasteState.equals(PasteState.DONE)) {
|
||||||
// All done. Cancel task
|
// All done. Cancel task
|
||||||
// Set pos1 and 2 if this was a clipboard paste
|
// Set pos1 and 2 if this was a clipboard paste
|
||||||
if (island == null && clipboard != null) {
|
if (island == null && clipboard != null) {
|
||||||
|
@ -425,6 +425,11 @@ commands:
|
|||||||
too-many-islands: "&cThere are too many islands in this world: there isn't enough room for yours to be created."
|
too-many-islands: "&cThere are too many islands in this world: there isn't enough room for yours to be created."
|
||||||
unable-create-island: "&cYour island could not be generated, please contact an administrator."
|
unable-create-island: "&cYour island could not be generated, please contact an administrator."
|
||||||
creating-island: "&aCreating your island, please wait a moment..."
|
creating-island: "&aCreating your island, please wait a moment..."
|
||||||
|
pasting:
|
||||||
|
estimated-time: "&aThis might take up to &b[number] &aseconds."
|
||||||
|
blocks: "&aPasting &b[number] &ablocks..."
|
||||||
|
entities: "&aPasting &b[number] &aentities..."
|
||||||
|
done: "&aYour island is ready!"
|
||||||
pick: "&aPick an island"
|
pick: "&aPick an island"
|
||||||
unknown-blueprint: "&cThat blueprint has not been loaded yet."
|
unknown-blueprint: "&cThat blueprint has not been loaded yet."
|
||||||
info:
|
info:
|
||||||
|
Loading…
Reference in New Issue
Block a user