3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-19 09:20:08 +01:00

Minor upstream merge

Dieser Commit ist enthalten in:
NotMyFault 2021-02-03 23:08:39 +01:00
Ursprung c1f6e43763
Commit ac16c9a2ba
14 geänderte Dateien mit 87 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -2,5 +2,5 @@
"extends": [ "extends": [
"config:base" "config:base"
], ],
"ignoreDeps": ["guava", "rhino-runtime", "mockito-core", "antlr4", "antlr4-runtime", "paranamer", "fastutil"] "ignoreDeps": ["guava", "rhino-runtime", "mockito-core", "antlr4", "antlr4-runtime", "paranamer", "fastutil", "auto-value-annotations", "auto-value"]
} }

Datei anzeigen

@ -213,6 +213,13 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
return plugin.getDescription().getVersion(); return plugin.getDescription().getVersion();
} }
// FAWE start
@Override
public String getId() {
return "intellectualsites:bukkit";
}
// FAWE end
@Override @Override
public Map<Capability, Preference> getCapabilities() { public Map<Capability, Preference> getCapabilities() {
Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class); Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class);

Datei anzeigen

@ -145,6 +145,13 @@ class CLIPlatform extends AbstractPlatform {
return app.getInternalVersion(); return app.getInternalVersion();
} }
// FAWE start
@Override
public String getId() {
return "intellectualsites:cli";
}
// FAWE end
@Override @Override
public Map<Capability, Preference> getCapabilities() { public Map<Capability, Preference> getCapabilities() {
Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class); Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class);

Datei anzeigen

@ -104,8 +104,11 @@ import com.sk89q.worldedit.regions.factory.RegionFactory;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -143,6 +146,10 @@ public class BrushCommands {
private final WorldEdit worldEdit; private final WorldEdit worldEdit;
private static final Component UNBIND_COMMAND_COMPONENT = TextComponent.builder("/brush unbind", TextColor.AQUA)
.clickEvent(ClickEvent.suggestCommand("/brush unbind"))
.build();
/** /**
* Create a new instance. * Create a new instance.
* *
@ -1034,6 +1041,7 @@ public class BrushCommands {
player.print( player.print(
Caption.of("fawe.worldedit.brush.brush.equipped", arguments.get().split(" ")[1])); Caption.of("fawe.worldedit.brush.brush.equipped", arguments.get().split(" ")[1]));
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
} }
return settings; return settings;
} }
@ -1267,5 +1275,6 @@ public class BrushCommands {
tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission); tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission);
player.printInfo(TranslatableComponent.of("worldedit.brush.operation.equip", TextComponent.of(factory.toString()))); player.printInfo(TranslatableComponent.of("worldedit.brush.operation.equip", TextComponent.of(factory.toString())));
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
} }
} }

Datei anzeigen

@ -53,6 +53,8 @@ import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.CommandManagerService; import org.enginehub.piston.CommandManagerService;
@ -70,6 +72,10 @@ import java.util.stream.Collectors;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class ToolCommands { public class ToolCommands {
private static final Component UNBIND_COMMAND_COMPONENT = TextComponent.builder("/tool unbind", TextColor.AQUA)
.clickEvent(ClickEvent.suggestCommand("/tool unbind"))
.build();
public static void register(CommandRegistrationHandler registration, public static void register(CommandRegistrationHandler registration,
CommandManager commandManager, CommandManager commandManager,
CommandManagerService commandManagerService, CommandManagerService commandManagerService,
@ -142,11 +148,16 @@ public class ToolCommands {
player.printInfo(TranslatableComponent.of(isBrush ? "worldedit.brush.none.equip" : "worldedit.tool.none.equip")); player.printInfo(TranslatableComponent.of(isBrush ? "worldedit.brush.none.equip" : "worldedit.tool.none.equip"));
} }
static void sendUnbindInstruction(Player sender, Component commandComponent) {
sender.printDebug(TranslatableComponent.of("worldedit.tool.unbind-instruction", commandComponent));
}
private static void setTool(Player player, LocalSession session, Tool tool, private static void setTool(Player player, LocalSession session, Tool tool,
String translationKey) throws InvalidToolBindException { String translationKey) throws InvalidToolBindException {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(itemStack.getType(), tool); session.setTool(itemStack.getType(), tool);
player.printInfo(TranslatableComponent.of(translationKey, itemStack.getRichName())); player.printInfo(TranslatableComponent.of(translationKey, itemStack.getRichName()));
sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
} }
private final WorldEdit we; private final WorldEdit we;

Datei anzeigen

@ -40,6 +40,7 @@ import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; 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 com.sk89q.worldedit.util.formatting.text.format.TextColor;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
@ -101,7 +102,8 @@ public class WorldEditCommands {
for (Platform platform : pm.getPlatforms()) { for (Platform platform : pm.getPlatforms()) {
producer.append( producer.append(
TextComponent.of("* ", TextColor.GRAY) TextComponent.of("* ", TextColor.GRAY)
.append(TextComponent.of(platform.getPlatformName())) .append(TextComponent.of(platform.getPlatformName())
.hoverEvent(HoverEvent.showText(TextComponent.of(platform.getId()))))
.append(TextComponent.of("(" + platform.getPlatformVersion() + ")")) .append(TextComponent.of("(" + platform.getPlatformVersion() + ")"))
).newline(); ).newline();
} }
@ -113,7 +115,7 @@ public class WorldEditCommands {
producer.append( producer.append(
TextComponent.of(capability.name(), TextColor.GRAY) TextComponent.of(capability.name(), TextColor.GRAY)
.append(TextComponent.of(": ") .append(TextComponent.of(": ")
.append(TextComponent.of(platform != null ? platform.getPlatformName() : "NONE"))) .append(TextComponent.of(platform != null ? platform.getPlatformName() : "none")))
).newline(); ).newline();
} }
actor.print(new MessageBox("Capabilities", producer, TextColor.GRAY).create()); actor.print(new MessageBox("Capabilities", producer, TextColor.GRAY).create());

Datei anzeigen

@ -21,6 +21,8 @@ package com.sk89q.worldedit.extension.platform;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.io.ResourceLoader; import com.sk89q.worldedit.util.io.ResourceLoader;
import com.sk89q.worldedit.world.DataFixer; import com.sk89q.worldedit.world.DataFixer;
@ -29,6 +31,7 @@ import com.sk89q.worldedit.world.registry.Registries;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -39,7 +42,7 @@ import javax.annotation.Nullable;
* <p>It is strongly recommended that implementations extend from * <p>It is strongly recommended that implementations extend from
* {@link AbstractPlatform}.</p> * {@link AbstractPlatform}.</p>
*/ */
public interface Platform { public interface Platform extends Keyed {
/** /**
* Return the resource loader. * Return the resource loader.
@ -176,6 +179,18 @@ public interface Platform {
*/ */
String getPlatformVersion(); String getPlatformVersion();
/**
* {@inheritDoc}
* @return an id
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
* for details
*/
@NonAbstractForCompatibility(delegateName = "getPlatformName", delegateParams = {})
@Override
default String getId() {
return "legacy:" + getPlatformName().toLowerCase(Locale.ROOT).replaceAll("[^a-z_.-]", "_");
}
/** /**
* Get a map of advertised capabilities of this platform, where each key * Get a map of advertised capabilities of this platform, where each key
* in the given map is a supported capability and the respective value * in the given map is a supported capability and the respective value

Datei anzeigen

@ -79,6 +79,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
final EllipsoidRegionSelector ellipsoidRegionSelector = (EllipsoidRegionSelector) oldSelector; final EllipsoidRegionSelector ellipsoidRegionSelector = (EllipsoidRegionSelector) oldSelector;
region = new EllipsoidRegion(ellipsoidRegionSelector.getIncompleteRegion()); region = new EllipsoidRegion(ellipsoidRegionSelector.getIncompleteRegion());
started = ellipsoidRegionSelector.started;
} else { } else {
Region oldRegion; Region oldRegion;
try { try {
@ -93,6 +94,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
BlockVector3 center = pos1.add(pos2).divide(2).floor(); BlockVector3 center = pos1.add(pos2).divide(2).floor();
region.setCenter(center); region.setCenter(center);
region.setRadius(pos2.subtract(center).toVector3()); region.setRadius(pos2.subtract(center).toVector3());
started = true;
} }
} }

Datei anzeigen

@ -62,6 +62,10 @@ public class Registry<V extends Keyed> implements Iterable<V> {
return value; return value;
} }
public void clear() {
this.map.clear();
}
public Set<String> keySet() { public Set<String> keySet() {
return Collections.unmodifiableSet(this.map.keySet()); return Collections.unmodifiableSet(this.map.keySet());
} }

Datei anzeigen

@ -39,6 +39,7 @@ import java.io.OutputStream;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
@ -107,7 +108,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
logFile = getString("log-file", logFile); logFile = getString("log-file", logFile);
logFormat = getString("log-format", logFormat); logFormat = getString("log-format", logFormat);
registerHelp = getBool("register-help", registerHelp); registerHelp = getBool("register-help", registerHelp);
wandItem = getString("wand-item", wandItem); wandItem = getString("wand-item", wandItem).toLowerCase(Locale.ROOT);
try { try {
wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId(); wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId();
} catch (Throwable ignored) { } catch (Throwable ignored) {
@ -117,7 +118,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
useInventory = getBool("use-inventory", useInventory); useInventory = getBool("use-inventory", useInventory);
useInventoryOverride = getBool("use-inventory-override", useInventoryOverride); useInventoryOverride = getBool("use-inventory-override", useInventoryOverride);
useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride); useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride);
navigationWand = getString("nav-wand-item", navigationWand); navigationWand = getString("nav-wand-item", navigationWand).toLowerCase(Locale.ROOT);
try { try {
navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId(); navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId();
} catch (Throwable ignored) { } catch (Throwable ignored) {

Datei anzeigen

@ -447,6 +447,8 @@
"worldedit.tool.lrbuild.set": "Left-click set to {0}; right-click set to {1}.", "worldedit.tool.lrbuild.set": "Left-click set to {0}; right-click set to {1}.",
"worldedit.tool.stack.equip": "Stack tool bound to {0}.", "worldedit.tool.stack.equip": "Stack tool bound to {0}.",
"worldedit.tool.unbind-instruction": "Run {0} while holding the item to unbind it.",
"worldedit.tool.superpickaxe.mode.single": "Mode is now single. Left click with a pickaxe. // to disable.", "worldedit.tool.superpickaxe.mode.single": "Mode is now single. Left click with a pickaxe. // to disable.",
"worldedit.tool.superpickaxe.mode.area": "Mode is now area. Left click with a pickaxe. // to disable.", "worldedit.tool.superpickaxe.mode.area": "Mode is now area. Left click with a pickaxe. // to disable.",
"worldedit.tool.superpickaxe.mode.recursive": "Mode is now recursive. Left click with a pickaxe. // to disable.", "worldedit.tool.superpickaxe.mode.recursive": "Mode is now recursive. Left click with a pickaxe. // to disable.",

Datei anzeigen

@ -189,6 +189,13 @@ class FabricPlatform extends AbstractPlatform implements MultiUserPlatform {
return mod.getInternalVersion(); return mod.getInternalVersion();
} }
// FAWE start
@Override
public String getId() {
return "intellectualsites:fabric";
}
// FAWE end
@Override @Override
public Map<Capability, Preference> getCapabilities() { public Map<Capability, Preference> getCapabilities() {
Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class); Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class);

Datei anzeigen

@ -195,6 +195,13 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
return mod.getInternalVersion(); return mod.getInternalVersion();
} }
// FAWE start
@Override
public String getId() {
return "intellectualsites:forge";
}
// FAWE end
@Override @Override
public Map<Capability, Preference> getCapabilities() { public Map<Capability, Preference> getCapabilities() {
Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class); Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class);

Datei anzeigen

@ -184,6 +184,13 @@ class SpongePlatform extends AbstractPlatform implements MultiUserPlatform {
return mod.getInternalVersion(); return mod.getInternalVersion();
} }
// FAWE start
@Override
public String getId() {
return "intellectualsites:sponge";
}
// FAWE end
@Override @Override
public Map<Capability, Preference> getCapabilities() { public Map<Capability, Preference> getCapabilities() {
Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class); Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class);