Skip to content

Commit

Permalink
add temporary workaround for console spam errors when checking old cu…
Browse files Browse the repository at this point in the history
…stom heads without a valid profile.
  • Loading branch information
crashdemons committed Feb 15, 2024
1 parent c851dfe commit 17fb99f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginLogger;
import org.shininet.bukkit.playerheads.PlayerHeads;

/**
* Abstract class defining methods for converting between entities, custom skullState type, and legacy username-skulls, etc.
Expand Down Expand Up @@ -92,6 +94,28 @@ public static TexturedSkullType skullTypeFromItemStack(ItemStack stack, boolean

return determineSkullType(op,skullState,filterCustomPlayerHeads,filterBlockedHeads);
}

@Deprecated
public static TexturedSkullType skullTypeFromItemStack_NoException(ItemStack stack, boolean filterCustomPlayerHeads, boolean filterBlockedHeads){
TexturedSkullType skullType = null;
try{ //FIXME: Temporary workaround!
skullType = SkullConverter.skullTypeFromItemStack(stack,filterCustomPlayerHeads,filterBlockedHeads);
}catch (IllegalArgumentException e){
PlayerHeads.instance.getLogger().warning("Ignoring unsupported legacy head profile from custom head: "+e.getMessage());
}
return skullType;
}

@Deprecated
public static TexturedSkullType skullTypeFromBlockState_NoException(BlockState state, boolean filterCustomPlayerHeads, boolean filterBlockedHeads){
TexturedSkullType skullType = null;
try{ //FIXME: Temporary workaround!
skullType = SkullConverter.skullTypeFromBlockState(state,filterCustomPlayerHeads,filterBlockedHeads);
}catch (IllegalArgumentException e){
PlayerHeads.instance.getLogger().warning("Ignoring unsupported legacy head profile from custom head: "+e.getMessage());
}
return skullType;
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ public void onItemSpawnEvent(ItemSpawnEvent event) {
if (!fixDroppedHeads) {
return;
}
TexturedSkullType skullType = SkullConverter.skullTypeFromItemStack(stack,true,true);
TexturedSkullType skullType = SkullConverter.skullTypeFromItemStack_NoException(stack,true,true);
if (skullType == null) {
return;
}
Expand Down Expand Up @@ -753,7 +753,7 @@ private ItemStack createConvertedMobhead(TexturedSkullType skullType, boolean is
//NOTE: the blockbreak handler expects this to unconditionally drop the item unless the new event is cancelled.
private BlockDropResult blockDrop(BlockEvent event, Block block, BlockState state, CompatibleProfile oldProfile) {
if(CompatiblePlugins.heads.getExternalHeadHandling(state)==HeadModificationHandling.NO_INTERACTION) return BlockDropResult.FAILED_BLOCKED_HEAD;//TODO: redundant code - SkullConverter checks custom & external heads now
TexturedSkullType skullType = SkullConverter.skullTypeFromBlockState(state,true,true);
TexturedSkullType skullType = SkullConverter.skullTypeFromBlockState_NoException(state,true,true);
if(skullType==null) return BlockDropResult.FAILED_BLOCKED_HEAD;
Location location = block.getLocation();
ItemStack item = null;
Expand Down Expand Up @@ -807,7 +807,7 @@ public void onBlockBreak(BlockBreakEvent event) {
if(CompatiblePlugins.heads.getExternalHeadHandling(block.getState())==HeadModificationHandling.NO_INTERACTION) return;//TODO: redundant code - SkullConverter checks custom & external heads now
if (player.getGameMode() != GameMode.CREATIVE) {
BlockState state = block.getState();
TexturedSkullType skullType = SkullConverter.skullTypeFromBlockState(state,true,true);
TexturedSkullType skullType = SkullConverter.skullTypeFromBlockState_NoException(state,true,true);
if (skullType != null) {

boolean canBreak = true;
Expand Down

0 comments on commit 17fb99f

Please sign in to comment.