This commit is contained in:
Jesse Boyd 2019-12-16 09:08:28 +00:00
commit ea5f7a77be
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
34 changed files with 170 additions and 227 deletions

View File

@ -5,10 +5,12 @@ on:
branches:
- master
- merge
- 1.15
pull_request:
branches:
- master
- merge
- 1.15
jobs:
test:

3
.gitignore vendored
View File

@ -24,3 +24,6 @@ todo.txt
mvn/*
docs/
*.sh
# i18n
worldedit-core/src/main/resources/lang/*
!worldedit-core/src/main/resources/lang/strings.json

View File

@ -13,7 +13,7 @@ logger.lifecycle("""
1) Read COMPILING.md if you haven't yet
2) Try running 'build' in a separate Gradle run
3) Use gradlew and not gradle
4) If you still need help, ask on Discord! https://discord.gg/enginehub
4) If you still need help, ask on Discord! https://discord.gg/ngZCzbU
Output files will be in [subproject]/build/libs
*******************************************

View File

@ -1,21 +0,0 @@
============= You are compiling: =============
_______ ___ ____ __ ____ _______
| ____| / \ \ \ / \ / / | ____|
| |__ / ^ \ \ \/ \/ / | |__
| __| / /_\ \ \ / | __|
| | / _____ \ \ /\ / | |____
|__| /__/ \__\ \__/ \__/ |_______|
======== Authors https://git.io/fjIDU ========
If you encounter trouble:
- Run `build` in a separate Gradle run
- Use gradlew and not gradle
- Ask us!
- https://discord.gg/ngZCzbU (Discord)
Files will be output to `/target`
==============================================

View File

@ -59,12 +59,10 @@ dependencies {
"implementation"("com.massivecraft:Factions:1.6.9.5-U0.2.1-SNAPSHOT") { isTransitive = false }
"implementation"("com.github.TechFortress:GriefPrevention:16.12.0") { isTransitive = false }
"implementation"("com.massivecraft:mcore:7.0.1") { isTransitive = false }
"implementation"("net.jzx7:regios:5.9.9") { isTransitive = false }
"implementation"("com.bekvon.bukkit.residence:Residence:4.5._13.1") { isTransitive = false }
"implementation"("com.palmergames.bukkit:towny:0.84.0.9") { isTransitive = false }
"implementation"("com.thevoxelbox.voxelsniper:voxelsniper:5.171.0") { isTransitive = false }
"implementation"("com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT") { isTransitive = false }
"implementation"("com.wasteofplastic:askyblock:3.0.8.2") { isTransitive = false }
}
tasks.named<Copy>("processResources") {

View File

@ -290,15 +290,6 @@ public class FaweBukkit implements IFawe, Listener {
}
}
final Plugin aSkyBlock = Bukkit.getServer().getPluginManager().getPlugin("ASkyBlock");
if (aSkyBlock != null && aSkyBlock.isEnabled()) {
try {
managers.add(new ASkyBlockHook(aSkyBlock));
log.debug("Attempting to use plugin 'ASkyBlock' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
}
if (Settings.IMP.EXPERIMENTAL.FREEBUILD) {
try {
managers.add(new FreeBuildRegion());

View File

@ -1,47 +0,0 @@
package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.regions.FaweMask;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import com.wasteofplastic.askyblock.Island;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
public class ASkyBlockHook extends BukkitMaskManager implements Listener {
public ASkyBlockHook(final Plugin aSkyBlock) {
super(aSkyBlock.getName());
}
public boolean isAllowed(Player player, Island island, MaskType type) {
return island != null && (player.getUniqueId().equals(island.getOwner()) || (type == MaskType.MEMBER && island.getMembers().contains(player.getUniqueId()) && hasMemberPermission(player)));
}
@Override
public FaweMask getMask(final com.sk89q.worldedit.entity.Player player, MaskType type) {
final Location location = BukkitAdapter.adapt(player).getLocation();
Island island = ASkyBlockAPI.getInstance().getIslandAt(location);
if (island != null && isAllowed(BukkitAdapter.adapt(player), island, type)) {
Location center1 = island.getCenter();
MutableBlockVector3 center = MutableBlockVector3.at(center1.getX(), center1.getY(), center1.getZ());
BlockVector3 pos1 = BlockVector3.at(island.getMinProtectedX(), 0, island.getMinProtectedZ());
MutableBlockVector3 pos2 = center.add(center.subtract(pos1)).mutY(255);
return new FaweMask(pos1, pos2) {
@Override
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
return isAllowed(BukkitAdapter.adapt(player), island, type);
}
};
}
return null;
}
}

View File

@ -19,10 +19,7 @@
package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extent.Extent;
@ -31,22 +28,24 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.BlockCommandSender;
import java.util.Locale;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.UUID;
import static com.google.common.base.Preconditions.checkNotNull;
public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements Locatable {
private static final String UUID_PREFIX = "CMD";
private final BlockCommandSender sender;
private final WorldEditPlugin plugin;
private final Location location;
@ -59,7 +58,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
this.plugin = plugin;
this.sender = sender;
this.location = BukkitAdapter.adapt(sender.getBlock().getLocation());
this.uuid = new UUID(location.toVector().toBlockPoint().hashCode(), location.getExtent().hashCode());
this.uuid = UUID.nameUUIDFromBytes((UUID_PREFIX + sender.getName()).getBytes(StandardCharsets.UTF_8));
}
@Override
@ -134,7 +133,6 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
@Override
public SessionKey getSessionKey() {
return new SessionKey() {
@Nullable
@Override
public String getName() {
return sender.getName();
@ -154,7 +152,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
@Override
public boolean isPersistent() {
return false;
return true;
}
@Override

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.component.TextUtils;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.RunnableVal;
@ -280,7 +281,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override
public Locale getLocale() {
return Locale.forLanguageTag(player.getLocale().replace('_', '-'));
return TextUtils.getLocaleByMinecraftTag(player.getLocale());
}
@Nullable

View File

@ -21,7 +21,7 @@ public class Settings extends Config {
@Final // Indicates that this value isn't configurable
public String ISSUES = "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues";
@Final
public String WIKI = "https://github.com/boy0001/FastAsyncWorldedit/wiki/";
public String WIKI = "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/wiki";
@Final
public String DATE; // These values are set from FAWE before loading
@Final
@ -364,7 +364,7 @@ public class Settings extends Config {
@Comment({
"[SAFE] Experimental scripting support for Java 9",
" - https://github.com/boy0001/FastAsyncWorldedit/wiki/JavaScript-API"
" - https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/wiki/JavaScript-API"
})
public boolean MODERN_CRAFTSCRIPTS = false;

View File

@ -24,6 +24,7 @@ import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
import com.sk89q.worldedit.util.formatting.component.TextUtils;
import com.sk89q.worldedit.util.logging.LogFormat;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@ -210,5 +211,12 @@ public abstract class LocalConfiguration {
return item;
}
public void setDefaultLocaleName(String localeName) {
this.defaultLocaleName = localeName;
if (localeName.equals("default")) {
this.defaultLocale = Locale.getDefault();
} else {
this.defaultLocale = TextUtils.getLocaleByMinecraftTag(localeName);
}
}
}

View File

@ -312,7 +312,7 @@ public class SelectionCommands {
)
@CommandPermissions("worldedit.wand.toggle")
public void toggleWand(Player player) {
player.print(TextComponent.of("The selection wand is now a normal tool. You can disable it with ")
player.printInfo(TextComponent.of("The selection wand is now a normal tool. You can disable it with ")
.append(TextComponent.of("/none", TextColor.AQUA).clickEvent(
ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/none")))
.append(TextComponent.of(" and rebind it to any item with "))
@ -383,7 +383,7 @@ public class SelectionCommands {
session.getRegionSelector(world).explainRegionAdjust(actor, session);
actor.print(TranslatableComponent.of("worldedit.shift.shifted"));
actor.printInfo(TranslatableComponent.of("worldedit.shift.shifted"));
} catch (RegionOperationException e) {
actor.printError(TextComponent.of(e.getMessage()));
}
@ -406,7 +406,7 @@ public class SelectionCommands {
region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session);
actor.print(TranslatableComponent.of("worldedit.outset.outset"));
actor.printInfo(TranslatableComponent.of("worldedit.outset.outset"));
}
@Command(
@ -426,7 +426,7 @@ public class SelectionCommands {
region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session);
actor.print(TranslatableComponent.of("worldedit.inset.inset"));
actor.printInfo(TranslatableComponent.of("worldedit.inset.inset"));
}
private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) {

View File

@ -186,7 +186,7 @@ public class WorldEditCommands {
actor.printInfo(TranslatableComponent.of("worldedit.timezone.set", TextComponent.of(tz.getDisplayName(
TextStyle.FULL, actor.getLocale()
))));
actor.print(TranslatableComponent.of("worldedit.timezone.current",
actor.printInfo(TranslatableComponent.of("worldedit.timezone.current",
TextComponent.of(dateFormat.withLocale(actor.getLocale()).format(ZonedDateTime.now(tz)))));
} catch (ZoneRulesException e) {
actor.printError(TranslatableComponent.of("worldedit.timezone.invalid"));

View File

@ -27,6 +27,7 @@ import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
import com.sk89q.worldedit.function.mask.Mask;
@ -104,8 +105,8 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
ParserContext parserContext = new ParserContext();
parserContext.setActor(actor);
if (actor instanceof Entity) {
Extent extent = ((Entity) actor).getExtent();
if (actor instanceof Locatable) {
Extent extent = ((Locatable) actor).getExtent();
if (extent instanceof World) {
parserContext.setWorld((World) extent);
}

View File

@ -166,13 +166,13 @@ public final class AsyncCommandBuilder<T> {
message = converted.getRichMessage();
}
}
sender.print(failure.append(TextComponent.of(": ")).append(message));
sender.printError(failure.append(TextComponent.of(": ")).append(message));
}
} else {
throw orig;
}
} catch (Throwable unknown) {
sender.print(failure.append(TextComponent.of(": Unknown error. Please see console.")));
sender.printError(failure.append(TextComponent.of(": Unknown error. Please see console.")));
logger.error("Uncaught exception occurred in task: " + description, orig);
}
}

View File

@ -19,10 +19,7 @@
package com.sk89q.worldedit.function.factory;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
import com.google.common.collect.Lists;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -42,8 +39,8 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import java.util.Collection;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
public class Deform implements Contextual<Operation> {
@ -160,6 +157,12 @@ public class Deform implements Contextual<Operation> {
session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout());
}
public enum Mode {
RAW_COORD,
OFFSET,
UNIT_CUBE
}
private static final class DeformOperation implements Operation {
private final Extent destination;
private final Region region;
@ -195,16 +198,10 @@ public class Deform implements Contextual<Operation> {
@Override
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of("worldedit.operation.deform.expression",
return ImmutableList.of(TranslatableComponent.of("worldedit.operation.deform.expression",
TextComponent.of(expression).color(TextColor.GRAY)));
}
}
public enum Mode {
RAW_COORD,
OFFSET,
UNIT_CUBE
}
}

View File

@ -19,54 +19,49 @@
package com.sk89q.worldedit.function.operation;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.object.extent.BlockTranslateExtent;
import com.boydti.fawe.object.extent.PositionTransformExtent;
import com.boydti.fawe.object.function.block.BiomeCopy;
import com.boydti.fawe.object.function.block.CombinedBlockCopy;
import com.boydti.fawe.object.function.block.SimpleBlockCopy;
import com.boydti.fawe.util.MaskTraverser;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.metadata.EntityProperties;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.CombinedRegionFunction;
import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.FlatRegionMaskingFilter;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.RegionMaskTestFunction;
import com.sk89q.worldedit.function.biome.ExtentBiomeCopy;
import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.entity.ExtentEntityCopy;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.function.visitor.EntityVisitor;
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
import com.sk89q.worldedit.function.visitor.IntersectRegionFunction;
import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.math.transform.Identity;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.entity.EntityTypes;
import java.util.Collections;
import com.sk89q.worldedit.util.formatting.text.Component;
import java.util.List;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.entity.EntityTypes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Makes a copy of a portion of one extent to another extent or another point.
*
@ -428,15 +423,14 @@ public class ForwardExtentCopy implements Operation {
@Override
public Iterable<Component> getStatusMessages() {
List<Component> messages = new ArrayList<>();
messages.add(TranslatableComponent.of("worldedit.operation.affected.block",
TextComponent.of(affectedBlocks)).color(TextColor.GRAY));
messages.add(TranslatableComponent.of("worldedit.operation.affected.biome",
TextComponent.of(affectedBiomeCols)).color(TextColor.GRAY));
messages.add(TranslatableComponent.of("worldedit.operation.affected.entity",
TextComponent.of(affectedEntities)).color(TextColor.GRAY));
return messages;
return ImmutableList.of(
TranslatableComponent.of("worldedit.operation.affected.block",
TextComponent.of(affectedBlocks)).color(TextColor.LIGHT_PURPLE),
TranslatableComponent.of("worldedit.operation.affected.biome",
TextComponent.of(affectedBiomeCols)).color(TextColor.LIGHT_PURPLE),
TranslatableComponent.of("worldedit.operation.affected.entity",
TextComponent.of(affectedEntities)).color(TextColor.LIGHT_PURPLE)
);
}
}

View File

@ -19,12 +19,15 @@
package com.sk89q.worldedit.function.operation;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -35,6 +38,11 @@ import java.util.stream.Collectors;
*/
public interface Operation {
/**
* This is an internal field, and should not be touched.
*/
Set<String> warnedDeprecatedClasses = new HashSet<>();
/**
* Complete the next step. If this method returns true, then the method may
* be called again in the future, or possibly never. If this method
@ -76,6 +84,13 @@ public interface Operation {
// TODO Remove legacy code WorldEdit 8.0.0
List<String> oldMessages = new ArrayList<>();
addStatusMessages(oldMessages);
if (oldMessages.size() > 0) {
String className = getClass().getName();
if (!warnedDeprecatedClasses.contains(className)) {
WorldEdit.logger.warn("An operation is using the old status message API. This will be removed in further versions. Class: " + className);
warnedDeprecatedClasses.add(className);
}
}
return oldMessages.stream().map(TextComponent::of).collect(Collectors.toList());
}
}

View File

@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.visitor;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.collection.BlockVectorSet;
@ -279,7 +279,7 @@ public abstract class BreadthFirstSearch implements Operation {
@Override
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
return ImmutableList.of(TranslatableComponent.of(
"worldedit.operation.affected.block",
TextComponent.of(getAffected())
).color(TextColor.GRAY));

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.function.visitor;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import static com.google.common.base.Preconditions.checkNotNull;
@ -84,7 +85,7 @@ public class EntityVisitor implements Operation {
@Override
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
return ImmutableList.of(TranslatableComponent.of(
"worldedit.operation.affected.entity",
TextComponent.of(getAffected())
).color(TextColor.GRAY));

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.function.visitor;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.google.common.collect.Lists;
@ -83,7 +84,7 @@ public class FlatRegionVisitor implements Operation {
@Override
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
return ImmutableList.of(TranslatableComponent.of(
"worldedit.operation.affected.column",
TextComponent.of(getAffected())
).color(TextColor.GRAY));

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.function.visitor;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
@ -95,7 +96,7 @@ public class RegionVisitor implements Operation {
@Override
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
return ImmutableList.of(TranslatableComponent.of(
"worldedit.operation.affected.block",
TextComponent.of(getAffected())
).color(TextColor.GRAY));

View File

@ -20,22 +20,21 @@
package com.sk89q.worldedit.regions;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
/**
* Region selectors create {@link Region}s from a series of "selected points."
* They are used, for example, to allow users to create a {@link CuboidRegion}
@ -77,8 +76,8 @@ public interface RegionSelector {
/**
* Tell the player information about his/her primary selection.
*
* @param actor the actor
* @param session the session
* @param actor the actor
* @param session the session
* @param position position
*/
void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position);
@ -86,8 +85,8 @@ public interface RegionSelector {
/**
* Tell the player information about his/her secondary selection.
*
* @param actor the actor
* @param session the session
* @param actor the actor
* @param session the session
* @param position position
*/
void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position);
@ -96,7 +95,7 @@ public interface RegionSelector {
* The the player information about the region's changes. This may resend
* all the defining region information if needed.
*
* @param actor the actor
* @param actor the actor
* @param session the session
*/
void explainRegionAdjust(Actor actor, LocalSession session);
@ -157,13 +156,13 @@ public interface RegionSelector {
/**
* Get lines of information about the selection.
*
*
* @return a list of lines describing the region
*/
@Deprecated
default List<String> getInformationLines() {
return Lists.newArrayList();
};
}
/**
* Get lines of information about the selection.
@ -172,12 +171,13 @@ public interface RegionSelector {
*/
default List<Component> getSelectionInfoLines() {
return getInformationLines().stream()
.map(TextComponent::of)
.map(line -> TextComponent.of(line, TextColor.LIGHT_PURPLE))
.collect(Collectors.toList());
}
/**
* Get the vertices
*
* @return
* @throws IncompleteRegionException
*/

View File

@ -39,7 +39,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
@ -123,12 +122,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
allowSymlinks = getBool("allow-symbolic-links", allowSymlinks);
serverSideCUI = getBool("server-side-cui", serverSideCUI);
extendedYLimit = getBool("extended-y-limit", extendedYLimit);
defaultLocaleName = getString("default-locale", defaultLocaleName);
if (defaultLocaleName.equals("default")) {
defaultLocale = Locale.getDefault();
} else {
defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-'));
}
setDefaultLocaleName(getString("default-locale", defaultLocaleName));
LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15));

View File

@ -30,7 +30,6 @@ import org.slf4j.Logger;
import java.io.IOException;
import java.util.HashSet;
import java.util.Locale;
/**
* A less simple implementation of {@link LocalConfiguration}
@ -128,12 +127,7 @@ public class YAMLConfiguration extends LocalConfiguration {
extendedYLimit = config.getBoolean("compat.extended-y-limit", false);
defaultLocaleName = config.getString("default-locale", defaultLocaleName);
if (defaultLocaleName.equals("default")) {
defaultLocale = Locale.getDefault();
} else {
defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-'));
}
setDefaultLocaleName(config.getString("default-locale", defaultLocaleName));
}
public void unload() {

View File

@ -23,6 +23,7 @@ import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.util.List;
import java.util.Locale;
public class TextUtils {
@ -46,4 +47,13 @@ public class TextUtils {
}
return builder.build();
}
/**
* Gets a Java Locale object by the Minecraft locale tag.
*
* @param locale The Minecraft locale tag
* @return A Java locale
*/
public static Locale getLocaleByMinecraftTag(String locale) {
return Locale.forLanguageTag(locale.replace('_', '-'));
}
}

View File

@ -28,18 +28,18 @@ public class ResourceLoader {
}
private static URL getResourceForgeHack(String location) throws IOException {
return new URL("modjar://worldedit/" + location);
try {
return new URL("modjar://worldedit/" + location);
} catch (Exception e) {
throw new IOException("Could not find " + location);
}
}
public static URL getResource(Class clazz, String name) throws IOException {
URL url = clazz.getResource(name);
if (url == null) {
try {
return getResourceForgeHack(clazz.getName().substring(0, clazz.getName().lastIndexOf('.')).replace(".", "/")
+ "/" + name);
} catch (Exception e) {
throw new IOException("Could not find " + name);
}
return getResourceForgeHack(clazz.getName().substring(0, clazz.getName().lastIndexOf('.')).replace(".", "/")
+ "/" + name);
}
return url;
}
@ -47,12 +47,8 @@ public class ResourceLoader {
public static URL getResourceRoot(String name) throws IOException {
URL url = ResourceLoader.class.getResource("/" + name);
if (url == null) {
try {
return getResourceForgeHack(name);
} catch (Exception e) {
throw new IOException("Could not find " + name);
}
return getResourceForgeHack(name);
}
return url;
}
}
}

View File

@ -19,8 +19,7 @@
package com.sk89q.worldedit.util.translation;
import com.google.common.io.Files;
import com.google.common.io.Resources;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
@ -29,21 +28,14 @@ import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.renderer.FriendlyComponentRenderer;
import com.sk89q.worldedit.util.io.ResourceLoader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
import java.lang.reflect.Type;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import static java.util.stream.Collectors.toMap;
/**
* Handles translations for the plugin.
@ -62,7 +54,7 @@ public class TranslationManager {
private static final Gson gson = new GsonBuilder().create();
private static final Type STRING_MAP_TYPE = new TypeToken<Map<String, String>>() {}.getType();
private final Map<Locale, Map<String, String>> translationMap = new HashMap<>();
private final Map<Locale, Map<String, String>> translationMap = new ConcurrentHashMap<>();
private final FriendlyComponentRenderer<Locale> friendlyComponentRenderer = FriendlyComponentRenderer.from(
(locale, key) -> new MessageFormat(getTranslationMap(locale).getOrDefault(key, key), locale));
private Locale defaultLocale = Locale.ENGLISH;
@ -80,8 +72,10 @@ public class TranslationManager {
}
private Map<String, String> filterTranslations(Map<String, String> translations) {
translations.entrySet().removeIf(entry -> entry.getValue().isEmpty());
return translations;
return translations.entrySet().stream()
.filter(e -> !e.getValue().isEmpty())
.map(e -> Maps.immutableEntry(e.getKey(), e.getValue().replace("'", "''")))
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
}
private Map<String, String> parseTranslationFile(InputStream inputStream) {
@ -95,7 +89,7 @@ public class TranslationManager {
baseTranslations = parseTranslationFile(ResourceLoader.getResourceRoot("lang/" + filename).openStream());
} catch (IOException e) {
// Seem to be missing base. If the user has provided a file use that.
baseTranslations = new HashMap<>();
baseTranslations = new ConcurrentHashMap<>();
}
File localFile = worldEdit.getWorkingDirectoryFile("lang/" + filename);
@ -117,7 +111,7 @@ public class TranslationManager {
}
checkedLocales.add(locale);
// Make a copy of the default language file
Map<String, String> baseTranslations = new HashMap<>();
Map<String, String> baseTranslations = new ConcurrentHashMap<>();
if (!locale.equals(defaultLocale)) {
baseTranslations.putAll(getTranslationMap(defaultLocale));
}

View File

@ -21,11 +21,14 @@ package com.sk89q.worldedit.world.registry;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.factory.BlockFactory;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Capability;
@ -34,11 +37,9 @@ import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.util.io.ResourceLoader;
import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
@ -49,13 +50,14 @@ import javax.annotation.Nullable;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Map;
import java.util.HashMap;
import java.util.Map;
public final class LegacyMapper {
private static final Logger log = LoggerFactory.getLogger(LegacyMapper.class);
private static LegacyMapper INSTANCE = new LegacyMapper();
static {
try {
INSTANCE.loadFromResource();
@ -64,12 +66,15 @@ public final class LegacyMapper {
}
}
private Map<String, String> blockEntries = new HashMap<>();
private final Int2ObjectArrayMap<Integer> blockStateToLegacyId4Data = new Int2ObjectArrayMap<>();
private final Int2ObjectArrayMap<Integer> extraId4DataToStateId = new Int2ObjectArrayMap<>();
private final int[] blockArr = new int[4096];
private final BiMap<Integer, ItemType> itemMap = HashBiMap.create();
private Map<String, String> blockEntries = new HashMap<>();
private Map<String, BlockState> stringToBlockMap = new HashMap<>();
private Multimap<BlockState, String> blockToStringMap = HashMultimap.create();
private Map<String, ItemType> stringToItemMap = new HashMap<>();
private Multimap<ItemType, String> itemToStringMap = HashMultimap.create();
/**
* Create a new instance.
@ -91,7 +96,8 @@ public final class LegacyMapper {
throw new IOException("Could not find legacy.json");
}
String source = Resources.toString(url, Charset.defaultCharset());
LegacyDataFile dataFile = gson.fromJson(source, new TypeToken<LegacyDataFile>() {}.getType());
LegacyDataFile dataFile = gson.fromJson(source, new TypeToken<LegacyDataFile>() {
}.getType());
DataFixer fixer = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataFixer();
ParserContext parserContext = new ParserContext();
@ -101,10 +107,10 @@ public final class LegacyMapper {
for (Map.Entry<String, String> blockEntry : dataFile.blocks.entrySet()) {
String id = blockEntry.getKey();
Integer combinedId = getCombinedId(blockEntry.getKey());
Integer combinedId = getCombinedId(blockEntry.getKey());
final String value = blockEntry.getValue();
blockEntries.put(id, value);
BlockState blockState = null;
BlockState blockState = null;
try {
blockState = BlockState.get(null, blockEntry.getValue());
BlockType type = blockState.getBlockType();
@ -112,18 +118,31 @@ public final class LegacyMapper {
blockState = blockState.with(PropertyKey.WATERLOGGED, false);
}
} catch (InputParseException e) {
BlockFactory blockFactory = WorldEdit.getInstance().getBlockFactory();
if (fixer != null) {
String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, 1631);
try {
blockState = WorldEdit.getInstance().getBlockFactory().parseFromInput(newEntry, parserContext).toImmutableState();
} catch (InputParseException ignored) {}
String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, 1631);
blockState = blockFactory.parseFromInput(newEntry, parserContext).toImmutableState();
} catch (InputParseException f) {
}
}
// if it's still null, the fixer was unavailable or failed
if (blockState == null) {
try {
blockState = blockFactory.parseFromInput(value, parserContext).toImmutableState();
} catch (InputParseException f) {
}
}
// if it's still null, both fixer and default failed
if (blockState == null) {
log.warn("Unknown block: " + value);
continue;
} else {
// it's not null so one of them succeeded, now use it
blockToStringMap.put(blockState, id);
stringToBlockMap.put(id, blockState);
}
}
blockArr[combinedId] = blockState.getInternalId();
blockArr[combinedId] = blockState.getInternalId();
blockStateToLegacyId4Data.put(blockState.getInternalId(), (Integer) combinedId);
blockStateToLegacyId4Data.putIfAbsent(blockState.getInternalBlockTypeId(), combinedId);
}

View File

@ -1 +0,0 @@
*/

View File

@ -7,7 +7,6 @@
"fawe.worldedit.history.find.element": "&8 - &2{0}: {1} &7ago &3{2}m &6{3} &c/{4}",
"fawe.worldedit.history.find.hover": "{0} blocks changed, click for more info",
"fawe.info.lighting.propagate.selection": "Lighting has been propogated in {0} chunks. (Note: To remove light use //removelight)",
"fawe.info.updated.lighting.selection": "Lighting has been updated in {0} chunks. (It may take a second for the packets to send)",
"fawe.info.set.region": "Selection set to your current allowed region",

View File

@ -34,6 +34,7 @@ import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.component.TextUtils;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
@ -209,7 +210,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override
public Locale getLocale() {
return Locale.forLanguageTag(player.language.replace('_', '-'));
return TextUtils.getLocaleByMinecraftTag(player.language);
}
@Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -34,7 +34,6 @@ import org.slf4j.Logger;
import java.io.IOException;
import java.util.HashSet;
import java.util.Locale;
public class ConfigurateConfiguration extends LocalConfiguration {
@ -131,11 +130,6 @@ public class ConfigurateConfiguration extends LocalConfiguration {
shellSaveType = type.equals("") ? null : type;
extendedYLimit = node.getNode("compat", "extended-y-limit").getBoolean(false);
defaultLocaleName = node.getNode("default-locale").getString(defaultLocaleName);
if (defaultLocaleName.equals("default")) {
defaultLocale = Locale.getDefault();
} else {
defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-'));
}
setDefaultLocaleName(node.getNode("default-locale").getString(defaultLocaleName));
}
}