mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 12:33:54 +00:00
Merge master, update to texts
This commit is contained in:
@ -29,6 +29,8 @@ import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.sk89q.worldedit.sponge.SpongeTextAdapter.convert;
|
||||
|
||||
public abstract class CommandAdapter implements CommandCallable {
|
||||
private Command command;
|
||||
|
||||
@ -51,24 +53,18 @@ public abstract class CommandAdapter implements CommandCallable {
|
||||
|
||||
@Override
|
||||
public Optional<Text> getShortDescription(CommandSource source) {
|
||||
String description = command.getDescription();
|
||||
if (!description.isEmpty()) {
|
||||
return Optional.of(Text.of(description));
|
||||
}
|
||||
return Optional.empty();
|
||||
return Optional.of(command.getDescription())
|
||||
.map(SpongeTextAdapter::convert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Text> getHelp(CommandSource source) {
|
||||
String help = command.getFullHelp();
|
||||
if (!help.isEmpty()) {
|
||||
return Optional.of(Text.of(help));
|
||||
}
|
||||
return Optional.empty();
|
||||
return Optional.of(command.getFullHelp())
|
||||
.map(SpongeTextAdapter::convert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getUsage(CommandSource source) {
|
||||
return Text.of(command.getUsage());
|
||||
return convert(command.getUsage());
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.adapter.spongeapi.TextAdapter;
|
||||
import org.spongepowered.api.command.CommandSource;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.text.Text;
|
||||
@ -89,6 +91,11 @@ public class SpongeCommandSender implements Actor {
|
||||
sendColorized(msg, TextColors.RED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(TextComponent component) {
|
||||
TextAdapter.sendComponent(sender, component);
|
||||
}
|
||||
|
||||
private void sendColorized(String msg, TextColor formatting) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.sendMessage(Text.of(formatting, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(part)));
|
||||
|
@ -36,6 +36,8 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.adapter.spongeapi.TextAdapter;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.data.type.HandTypes;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
@ -149,6 +151,11 @@ public class SpongePlayer extends AbstractPlayerActor {
|
||||
sendColorized(msg, TextColors.RED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(TextComponent component) {
|
||||
TextAdapter.sendComponent(player, component);
|
||||
}
|
||||
|
||||
private void sendColorized(String msg, TextColor formatting) {
|
||||
for (String part : msg.split("\n")) {
|
||||
this.player.sendMessage(Text.of(formatting, TextSerializers.FORMATTING_CODE.deserialize(part)));
|
||||
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.sponge;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
|
||||
public class SpongeTextAdapter {
|
||||
|
||||
public static Text convert(Component component) {
|
||||
return TextSerializers.JSON.deserialize(GsonComponentSerializer.INSTANCE.serialize(component));
|
||||
}
|
||||
|
||||
private SpongeTextAdapter() {
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user