Merge master, update to texts

This commit is contained in:
Kenzie Togami
2019-04-25 22:11:46 -07:00
63 changed files with 731 additions and 1332 deletions

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.bukkit;
import com.google.common.collect.ImmutableMap;
import com.sk89q.bukkit.util.CommandInspector;
import com.sk89q.worldedit.extension.platform.Actor;
import org.bukkit.command.Command;
@ -37,6 +36,7 @@ import org.slf4j.LoggerFactory;
import java.util.Optional;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.bukkit.BukkitTextAdapter.reduceToText;
class BukkitCommandInspector implements CommandInspector {
@ -55,7 +55,7 @@ class BukkitCommandInspector implements CommandInspector {
public String getShortText(Command command) {
Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName());
if (mapping.isPresent()) {
return mapping.get().getDescription();
return reduceToText(mapping.get().getDescription());
} else {
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available";
@ -66,7 +66,7 @@ class BukkitCommandInspector implements CommandInspector {
public String getFullText(Command command) {
Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName());
if (mapping.isPresent()) {
return mapping.get().getFullHelp();
return reduceToText(mapping.get().getFullHelp());
} else {
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available";

View File

@ -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.bukkit.TextAdapter;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -91,6 +93,11 @@ public class BukkitCommandSender implements Actor {
}
}
@Override
public void print(TextComponent component) {
TextAdapter.sendComponent(sender, component);
}
@Override
public boolean canDestroyBedrock() {
return true;

View File

@ -37,7 +37,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -125,6 +126,11 @@ public class BukkitPlayer extends AbstractPlayerActor {
}
}
@Override
public void print(TextComponent component) {
TextAdapter.sendComponent(player, component);
}
@Override
public void setPosition(Vector3 pos, float pitch, float yaw) {
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(),

View File

@ -28,7 +28,6 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.MultiUserPlatform;
import com.sk89q.worldedit.extension.platform.Preference;
import com.sk89q.worldedit.util.command.CommandMapping;
import com.sk89q.worldedit.world.registry.Registries;
import org.bukkit.Bukkit;
import org.bukkit.Server;
@ -45,6 +44,8 @@ import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.sk89q.worldedit.bukkit.BukkitTextAdapter.reduceToText;
public class BukkitServerInterface implements MultiUserPlatform {
public Server server;
public WorldEditPlugin plugin;
@ -132,8 +133,8 @@ public class BukkitServerInterface implements MultiUserPlatform {
Stream.of(command.getName()),
command.getAliases().stream()
).toArray(String[]::new);
return new CommandInfo(command.getUsage(),
command.getDescription(), aliases,
return new CommandInfo(reduceToText(command.getUsage()),
reduceToText(command.getDescription()), aliases,
inspector, permissionsArray);
}).collect(Collectors.toList()));
}

View File

@ -0,0 +1,48 @@
/*
* 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.bukkit;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
public class BukkitTextAdapter {
public static String reduceToText(Component component) {
StringBuilder text = new StringBuilder();
appendTextTo(text, component);
return text.toString();
}
private static void appendTextTo(StringBuilder builder, Component component) {
if (component instanceof TextComponent) {
builder.append(((TextComponent) component).content());
} else if (component instanceof TranslatableComponent) {
builder.append(((TranslatableComponent) component).key());
}
for (Component child : component.children()) {
appendTextTo(builder, child);
}
}
private BukkitTextAdapter() {
}
}

View File

@ -52,7 +52,7 @@ public class BukkitImplLoader {
"**\n" +
"** When working with blocks or undoing, chests will be empty, signs\n" +
"** will be blank, and so on. There will be no support for entity\n" +
"** and biome-related functions.\n" +
"** and block property-related functions.\n" +
"**\n" +
"** Please see http://wiki.sk89q.com/wiki/WorldEdit/Bukkit_adapters\n" +
"**********************************************\n";