Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Sep 14, 2021
1 parent 1a681c7 commit 966e589
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
16 changes: 10 additions & 6 deletions src/main/java/org/samo_lego/fabrictailor/config/TailorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,26 @@
public class TailorConfig {
private static final Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting().disableHtmlEscaping().create();


@SerializedName("// Whether to allow players to have capes. WARNING! This will toggle ALL capes!")
public final String _comment_allowCapes = "(default: true)";
@SerializedName("allow_capes")
public boolean allowCapes = true;

@SerializedName("// Default skin for new players. Use command `/fabrictailor setDefaultSkin` to set those values.")
public final String _comment_defaultSkin = "";
@SerializedName("default_skin")
public DefaultSkin defaultSkin = new DefaultSkin();

public static class DefaultSkin {
@SerializedName("// Whether to apply the default skin to ALL new players, not just those without skin.")
public final String _comment_applyToAll = "(default: false)";
@SerializedName("apply_to_all")
public boolean applyToAll = false;
public String value = "";
public String signature = "";
}

@SerializedName("// Whether to allow players to have capes. WARNING! This will toggle ALL capes!")
public final String _comment_allowCapes = "(default: true)";
@SerializedName("allow_capes")
public boolean allowCapes = true;


/**
* Loads config file.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,25 @@ public abstract class MixinPlayerManager {
private void onPlayerConnect(ClientConnection clientConnection, ServerPlayerEntity player, CallbackInfo ci) {
String value = ((TailoredPlayer) player).getSkinValue();
String signature = ((TailoredPlayer) player).getSkinSignature();

if(value == null || signature == null) {
value = config.defaultSkin.value;
signature = config.defaultSkin.signature;

Property skinData;
if(!value.isEmpty() && !signature.isEmpty()) {
skinData = new Property("textures", value, signature);
} else {
// Trying to fetch skin by playername

Property skinData = null;

if(!config.defaultSkin.applyToAll)
skinData = fetchSkinByName(player.getGameProfile().getName());

if(skinData == null) {
value = config.defaultSkin.value;
signature = config.defaultSkin.signature;

if(!value.isEmpty() && !signature.isEmpty())
skinData = new Property("textures", value, signature);
}

((TailoredPlayer) player).setSkin(skinData, false);
// Try to set skin now
if(skinData != null)
((TailoredPlayer) player).setSkin(skinData, false);
}

}
}

0 comments on commit 966e589

Please sign in to comment.