mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Upstream changes (#717)
* Perform part of the move of //fast to //perf (#1377) This re-adds a deprecated `//fast` and moves the current logic to `//perf`. Later `//perf` will have its syntax reworked, when Piston finally supports sub-commands properly! * Names via Translation (#1268) * Deprecate BiomeRegistry, etc. * Update some libraries, e.g. text * Move to new translation renderer * Revert "Deprecate BiomeRegistry, etc." This reverts commit 59a5d6c92aec52739a8dc68ac3d23898af7593dd. This was not a good idea for potential mod shenanigans. * Move BiomeData#getName to BiomeRegistry, use i18n * Use getRichName instead of getName * Implement getRichName for NullBiomeRegistry * Add getRichName for blocks * Relocate net.kyori.minecraft * Update adapters for getRichBlockName * Add getRichName for items * Update adapters for getRichItemName * Update adapters JAR for merge (cherry picked from commit cfd26253b6fb59ff6c65a0157a6780be7db4ea5a) * Follow-up fixes for 92f877679622a27b16b9e5cd61cfec1a6545be33 * Don't send deprecation warning and improve info message * Fix click command for perf box (cherry picked from commit 7ee60060c31df2f8b41212b430a0875312189339) * update R3 adapter§ Co-authored-by: Octavia Togami <octavia.togami@gmail.com> Co-authored-by: NotMyFault <mc.cache@web.de> Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com> Co-authored-by: Aurora <aurora@relanet.eu>
This commit is contained in:
@ -21,17 +21,19 @@ package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class PaginationBox extends MessageBox {
|
||||
|
||||
@ -138,53 +140,30 @@ public abstract class PaginationBox extends MessageBox {
|
||||
}
|
||||
|
||||
public static <T> PaginationBox fromStrings(String header, @Nullable String pageCommand, Collection<T> lines, Function<T, Component> adapt) {
|
||||
return fromStrings(header, pageCommand, Collections2.transform(lines, adapt));
|
||||
return fromComponents(header, pageCommand, Collections2.transform(lines, adapt));
|
||||
}
|
||||
|
||||
public static PaginationBox fromStrings(String header, @Nullable String pageCommand, Collection lines) {
|
||||
public static PaginationBox fromStrings(String header, @Nullable String pageCommand, Collection<String> lines) {
|
||||
return fromComponents(header, pageCommand, lines.stream()
|
||||
.map(TextComponent::of)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public static PaginationBox fromComponents(String header, @Nullable String pageCommand, Collection<Component> lines) {
|
||||
return new ListPaginationBox(header, pageCommand, lines);
|
||||
}
|
||||
|
||||
public static PaginationBox fromStrings(String header, @Nullable String pageCommand, List<String> lines) {
|
||||
return fromStrings(header, pageCommand, (Collection) lines);
|
||||
}
|
||||
private static class ListPaginationBox extends PaginationBox {
|
||||
private final List<Component> lines;
|
||||
|
||||
public static class ListPaginationBox extends PaginationBox {
|
||||
private final Collection lines;
|
||||
private int iterIndex;
|
||||
private Iterator iterator;
|
||||
|
||||
public ListPaginationBox(String header, String pageCommand, List<String> lines) {
|
||||
this(header, pageCommand, (Collection) lines);
|
||||
}
|
||||
|
||||
public ListPaginationBox(String header, String pageCommand, Collection lines) {
|
||||
ListPaginationBox(String header, String pageCommand, Collection<Component> lines) {
|
||||
super(header, pageCommand);
|
||||
this.lines = lines;
|
||||
this.lines = ImmutableList.copyOf(lines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent(int number) {
|
||||
Object obj;
|
||||
if (lines instanceof List) {
|
||||
obj = ((List) lines).get(number);
|
||||
} else {
|
||||
if (iterator == null || iterIndex > number) {
|
||||
iterator = lines.iterator();
|
||||
iterIndex = 0;
|
||||
}
|
||||
do {
|
||||
obj = iterator.next();
|
||||
iterIndex++;
|
||||
} while (iterIndex < number);
|
||||
}
|
||||
if (obj instanceof Supplier) {
|
||||
obj = ((Supplier) obj).get();
|
||||
}
|
||||
if (obj instanceof Component) {
|
||||
return (Component) obj;
|
||||
}
|
||||
return TextComponent.of(obj + "");
|
||||
return lines.get(number);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,7 +70,7 @@ public class SideEffectBox extends PaginationBox {
|
||||
for (SideEffect.State uiState : SHOWN_VALUES) {
|
||||
builder = builder.append(TextComponent.space());
|
||||
builder = builder.append(TranslatableComponent.of(uiState.getDisplayName(), uiState == state ? TextColor.WHITE : TextColor.GRAY)
|
||||
.clickEvent(ClickEvent.runCommand("//fast -h " + effect.name().toLowerCase(Locale.US) + " " + uiState.name().toLowerCase(Locale.US)))
|
||||
.clickEvent(ClickEvent.runCommand("//perf -h " + effect.name().toLowerCase(Locale.US) + " " + uiState.name().toLowerCase(Locale.US)))
|
||||
.hoverEvent(HoverEvent.showText(uiState == state
|
||||
? TranslatableComponent.of("worldedit.sideeffect.box.current")
|
||||
: TranslatableComponent.of("worldedit.sideeffect.box.change-to", TranslatableComponent.of(uiState.getDisplayName()))
|
||||
|
Reference in New Issue
Block a user