diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 5337fe720..13379f853 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -34,6 +34,7 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.internal.cui.CUIEvent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.ConvexPolyhedralRegion; @@ -62,6 +63,7 @@ import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; +import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.io.File; @@ -76,6 +78,8 @@ import java.util.concurrent.atomic.AtomicInteger; */ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + //FAWE start private final Map meta; @@ -93,7 +97,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (fe != null) { printError(fe.getComponent()); } else { - throwable.printStackTrace(); + LOGGER.error("Error occurred executing player action", throwable); } } }, this::getUniqueId); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 9f798e21c..72feee18d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -273,9 +273,7 @@ public class PlatformManager { public T createProxyActor(T base) { checkNotNull(base); - if (base instanceof Player) { - Player player = (Player) base; - + if (base instanceof Player player) { Player permActor = queryCapability(Capability.PERMISSIONS).matchPlayer(player); if (permActor == null) { permActor = player; @@ -389,10 +387,9 @@ public class PlatformManager { Location location = event.getLocation(); // At this time, only handle interaction from players - if (!(actor instanceof Player)) { + if (!(actor instanceof Player player)) { return; } - Player player = (Player) actor; LocalSession session = worldEdit.getSessionManager().get(actor); Request.reset(); @@ -463,7 +460,7 @@ public class PlatformManager { } else { actor.print(Caption.of("worldedit.command.error.report")); actor.print(TextComponent.of(e.getClass().getName()+ ": " + e.getMessage())); - e.printStackTrace(); + LOGGER.error("Error occurred executing player action", e); } } //FAWE end @@ -511,14 +508,7 @@ public class PlatformManager { } //FAWE start - add own message } catch (Throwable e) { - FaweException faweException = FaweException.get(e); - if (faweException != null) { - player.print(Caption.of("fawe.cancel.reason", faweException.getComponent())); - } else { - player.print(Caption.of("worldedit.command.error.report")); - player.print(TextComponent.of(e.getClass().getName() + ": " + e.getMessage())); - e.printStackTrace(); - } + handleThrowable(e, player); //FAWE end } finally { Request.reset(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java index 95f2c2585..b6a12cb7c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java @@ -312,6 +312,11 @@ public class BlockState implements BlockStateHolder, Pattern { return newState != this.getInternalId() ? type.withStateId(newState) : this; } catch (ClassCastException e) { throw new IllegalArgumentException("Property not found: " + property); + } catch (Exception e) { + throw new UnsupportedOperationException( + "Error resolving property " + property.getName() + " for block type " + getBlockType().id() + "(nullable) value " + value, + e + ); } } @@ -322,6 +327,11 @@ public class BlockState implements BlockStateHolder, Pattern { return (V) ap.getValue(this.getInternalId()); } catch (ClassCastException e) { throw new IllegalArgumentException("Property not found: " + property); + } catch (Exception e) { + throw new UnsupportedOperationException( + "Error resolving property " + property.getName() + " for blocktype " + getBlockType().id(), + e + ); } } @@ -337,6 +347,11 @@ public class BlockState implements BlockStateHolder, Pattern { return newState != this.getInternalId() ? type.withStateId(newState) : this; } catch (ClassCastException e) { throw new IllegalArgumentException("Property not found: " + property); + } catch (Exception e) { + throw new UnsupportedOperationException( + "Error resolving property " + property.getName() + " for block type " + getBlockType().id() + "(nullable) value " + value, + e + ); } }