Update upstream

This commit is contained in:
NotMyFault 2020-01-08 19:36:12 +01:00
parent 1414859773
commit 3ee920f9e6
8 changed files with 31 additions and 90 deletions

View File

@ -44,7 +44,10 @@ import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.WorldEditText;
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.adapter.bukkit.TextAdapter; import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -282,6 +285,15 @@ public class BukkitPlayer extends AbstractPlayerActor {
return TextUtils.getLocaleByMinecraftTag(player.getLocale()); return TextUtils.getLocaleByMinecraftTag(player.getLocale());
} }
@Override
public void sendAnnouncements() {
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() == null) {
printError(TranslatableComponent.of("worldedit.version.bukkit.unsupported-adapter",
TextComponent.of("https://intellectualsites.github.io/download/fawe.html", TextColor.AQUA)
.clickEvent(ClickEvent.openUrl("https://intellectualsites.github.io/download/fawe.html"))));
}
}
@Nullable @Nullable
@Override @Override
public <T> T getFacet(Class<? extends T> cls) { public <T> T getFacet(Class<? extends T> cls) {

View File

@ -156,6 +156,7 @@ public class LocalSession implements TextureHolder {
private transient List<Countable<BlockState>> lastDistribution; private transient List<Countable<BlockState>> lastDistribution;
private transient World worldOverride; private transient World worldOverride;
private transient boolean tickingWatchdog = false; private transient boolean tickingWatchdog = false;
private transient boolean hasBeenToldVersion;
// Saved properties // Saved properties
private String lastScript; private String lastScript;
@ -1199,6 +1200,9 @@ public class LocalSession implements TextureHolder {
* @param actor the actor * @param actor the actor
*/ */
public void tellVersion(Actor actor) { public void tellVersion(Actor actor) {
if (hasBeenToldVersion) return;
hasBeenToldVersion = true;
actor.sendAnnouncements();
} }
public boolean shouldUseServerCUI() { public boolean shouldUseServerCUI() {

View File

@ -1,87 +0,0 @@
/*
* 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.command.argument;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import java.util.concurrent.locks.StampedLock;
/**
* Lazily-created {@link EditSession}.
*/
public class EditSessionHolder {
private final StampedLock lock = new StampedLock();
private final WorldEdit worldEdit;
private final Player player;
public EditSessionHolder(WorldEdit worldEdit, Player player) {
this.worldEdit = worldEdit;
this.player = player;
}
private EditSession session;
/**
* Get the session, but does not create it if it doesn't exist.
*/
public EditSession getSession() {
long stamp = lock.tryOptimisticRead();
EditSession result = session;
if (!lock.validate(stamp)) {
stamp = lock.readLock();
try {
result = session;
} finally {
lock.unlockRead(stamp);
}
}
return result;
}
public EditSession getOrCreateSession() {
// use the already-generated result if possible
EditSession result = getSession();
if (result != null) {
return result;
}
// otherwise, acquire write lock
long stamp = lock.writeLock();
try {
// check session field again -- maybe another writer hit it in between
result = session;
if (result != null) {
return result;
}
// now we can do the actual creation
LocalSession localSession = worldEdit.getSessionManager().get(player);
EditSession editSession = localSession.createEditSession(player);
editSession.enableStandardMode();
localSession.tellVersion(player);
return session = editSession;
} finally {
lock.unlockWrite(stamp);
}
}
}

View File

@ -186,7 +186,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (context.getActor() != null) { if (context.getActor() != null) {
throw new NoMatchException("Unknown property " + parts[0] + " for block " + type.getId()); throw new NoMatchException("Unknown property " + parts[0] + " for block " + type.getId());
} else { } else {
WorldEdit.logger.warn("Unknown property " + parts[0] + " for block " + type.getId()); WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.getId());
} }
return Maps.newHashMap(); return Maps.newHashMap();
} }

View File

@ -275,4 +275,10 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
* @return The locale * @return The locale
*/ */
Locale getLocale(); Locale getLocale();
/**
* Sends any relevant notices to the user when they first use WorldEdit in a session.
*/
default void sendAnnouncements() {
}
} }

View File

@ -172,6 +172,11 @@ public class PlayerProxy extends AbstractPlayerActor {
cuiActor.dispatchCUIEvent(event); cuiActor.dispatchCUIEvent(event);
} }
@Override
public void sendAnnouncements() {
basePlayer.sendAnnouncements();
}
@Nullable @Nullable
@Override @Override
public <T> T getFacet(Class<? extends T> cls) { public <T> T getFacet(Class<? extends T> cls) {

View File

@ -135,7 +135,7 @@ public final class LegacyMapper {
} }
// if it's still null, both fixer and default failed // if it's still null, both fixer and default failed
if (blockState == null) { if (blockState == null) {
log.warn("Unknown block: " + value); log.debug("Unknown block: " + value);
} else { } else {
// it's not null so one of them succeeded, now use it // it's not null so one of them succeeded, now use it
blockToStringMap.put(blockState, id); blockToStringMap.put(blockState, id);
@ -173,7 +173,7 @@ public final class LegacyMapper {
} catch (Exception e) { } catch (Exception e) {
} }
} }
log.warn("Unknown item: " + value); log.debug("Unknown item: " + value);
} }
} }

View File

@ -563,6 +563,7 @@
"worldedit.timezone.set": "Timezone set for this session to: {0}", "worldedit.timezone.set": "Timezone set for this session to: {0}",
"worldedit.timezone.current": "The current time in that timezone is: {0}", "worldedit.timezone.current": "The current time in that timezone is: {0}",
"worldedit.version.version": "FAWE version:\n - Date {0}\n - Commit {1}\n - Build {2}\n - Platform {3}", "worldedit.version.version": "FAWE version:\n - Date {0}\n - Commit {1}\n - Build {2}\n - Platform {3}",
"worldedit.version.bukkit.unsupported-adapter": "This FAWE version does not fully support your version of Bukkit. Block entities (e.g. chests) will be empty, block properties (e.g. rotation) will be missing, and other things may not work. Update FAWE to restore this functionality:\n{0}",
"worldedit.command.time-elapsed": "{0}s elapsed (history: {1} changed; {2} blocks/sec).", "worldedit.command.time-elapsed": "{0}s elapsed (history: {1} changed; {2} blocks/sec).",
"worldedit.command.permissions": "You are not permitted to do that. Are you in the right mode?", "worldedit.command.permissions": "You are not permitted to do that. Are you in the right mode?",