3333import com .sk89q .worldedit .extent .Extent ;
3434import com .sk89q .worldedit .extent .inventory .BlockBag ;
3535import com .sk89q .worldedit .internal .cui .CUIEvent ;
36+ import com .sk89q .worldedit .internal .util .LogManagerCompat ;
3637import com .sk89q .worldedit .math .BlockVector3 ;
3738import com .sk89q .worldedit .math .Vector3 ;
3839import com .sk89q .worldedit .session .SessionKey ;
5152import com .sk89q .worldedit .world .block .BlockTypes ;
5253import com .sk89q .worldedit .world .gamemode .GameMode ;
5354import com .sk89q .worldedit .world .gamemode .GameModes ;
55+ import org .apache .logging .log4j .Logger ;
5456import org .bukkit .Bukkit ;
5557import org .bukkit .Location ;
5658import org .bukkit .Material ;
7375
7476public class BukkitPlayer extends AbstractPlayerActor {
7577
78+ private static final Logger LOGGER = LogManagerCompat .getLogger ();
79+
7680 private final Player player ;
7781 private final WorldEditPlugin plugin ;
7882 //FAWE start
79- private final PermissionAttachment permAttachment ;
83+ private PermissionAttachment permAttachment = null ;
8084
8185 /**
8286 * This constructs a new {@link BukkitPlayer} for the given {@link Player}.
@@ -89,7 +93,6 @@ public BukkitPlayer(@Nullable Player player) {
8993 super (player != null ? getExistingMap (WorldEditPlugin .getInstance (), player ) : new ConcurrentHashMap <>());
9094 this .plugin = WorldEditPlugin .getInstance ();
9195 this .player = player ;
92- this .permAttachment = plugin .getPermissionAttachmentManager ().getOrAddAttachment (player );
9396 }
9497 //FAWE end
9598
@@ -105,7 +108,6 @@ public BukkitPlayer(@Nonnull WorldEditPlugin plugin, @Nullable Player player) {
105108 this .plugin = plugin ;
106109 this .player = player ;
107110 //FAWE start
108- this .permAttachment = plugin .getPermissionAttachmentManager ().getOrAddAttachment (player );
109111 if (player != null && Settings .settings ().CLIPBOARD .USE_DISK ) {
110112 BukkitPlayer cached = WorldEditPlugin .getInstance ().getCachedPlayer (player );
111113 if (cached == null ) {
@@ -297,6 +299,17 @@ public void setPermission(String permission, boolean value) {
297299 }
298300 }
299301 if (usesuperperms ) {
302+ if (this .permAttachment == null ) {
303+ this .permAttachment = plugin .getPermissionAttachmentManager ().getOrAddAttachment (player );
304+ }
305+ if (this .permAttachment == null ) {
306+ LOGGER .warn (
307+ "Attempted to set permission for offline player `{}`, UUID: `{}`?!" ,
308+ player .getName (),
309+ player .getUniqueId ()
310+ );
311+ return ;
312+ }
300313 permAttachment .setPermission (permission , value );
301314 }
302315 }
0 commit comments