Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
More work on UI's, modified the coremod. Implemented the update checker.
Browse files Browse the repository at this point in the history
Apparently patches #21 which means the mod is now useable. If you want to use SkinChanger at this point, you will need to enable the "All me" option in the config settings.

I've temporarily disabled the "Recent Capes" and "Recent Skins menu until it's implemented at a later date"
  • Loading branch information
boomboompower committed Aug 31, 2020
1 parent 2bc7c1c commit b54f98e
Show file tree
Hide file tree
Showing 23 changed files with 488 additions and 230 deletions.
20 changes: 19 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import proguard.gradle.ProGuardTask

buildscript {
repositories {
jcenter()
Expand All @@ -25,12 +27,14 @@ buildscript {
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT"
classpath 'net.sf.proguard:proguard-gradle:6.0.3'
classpath 'net.sf.proguard:proguard-base:6.0.3'
}
}

apply plugin: "net.minecraftforge.gradle.forge"

version = '3.0.0'
version = '3.0.2'
group = "wtf.boomy.skinchanger"
archivesBaseName = "SkinChangerMod"

Expand All @@ -46,6 +50,10 @@ minecraft {

// The mapping to use http://export.mcpbot.bspk.rs/stable/
mappings = "stable_22"

replace '@VERSION@', this.version
replace '@MC_VERSION@', "1.8.9"
replace '@FINGERPRINT@', System.getenv('SHA1Signature') ?: ""
}

repositories {
Expand All @@ -58,6 +66,7 @@ repositories {

// General mod dependencies
dependencies {
provided 'com.github.boomboompower:ApagogeJava:master-SNAPSHOT'
}


Expand Down Expand Up @@ -94,6 +103,7 @@ jar {
from configurations.provided.asFileTree.files.collect {
// Fixes an issue where Mixin's copies a duplicate file into the build jar...
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'com/google/*/**'

zipTree(it)
}
Expand Down Expand Up @@ -133,5 +143,13 @@ sourceSets {
// configuration (this makes it inherit similar build properties)
configurations {
provided

compile.extendsFrom(provided)
}

task proguard(type: ProGuardTask) {
configuration 'proguard/proguard.txt'

injars "build/libs/${jar.archiveName}"
outjars "build/libs/PRO-${jar.archiveName}"
}
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Sun Aug 30 14:45:27 AEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip
67 changes: 50 additions & 17 deletions src/main/java/wtf/boomy/mods/skinchanger/SkinChangerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
import com.mojang.authlib.GameProfile;

import net.minecraft.client.network.NetworkPlayerInfo;

import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import wtf.boomy.apagoge.ApagogeHandler;
import wtf.boomy.mods.skinchanger.commands.SkinCommand;
import wtf.boomy.mods.skinchanger.configuration.ConfigurationHandler;
import wtf.boomy.mods.skinchanger.cosmetic.CosmeticFactory;
Expand All @@ -36,18 +37,19 @@
import wtf.boomy.mods.skinchanger.utils.game.ChatColor;

import java.io.File;
import java.net.URISyntaxException;

/**
* The Official SkinChanger mod
*
* @author boombompower
* @version 3.0.0
*/
@Mod(modid = SkinChangerMod.MOD_ID, version = SkinChangerMod.VERSION, acceptedMinecraftVersions = "[1.8.8,1.8.9]", clientSideOnly = true)
@Mod(modid = SkinChangerMod.MOD_ID, version = SkinChangerMod.VERSION, acceptedMinecraftVersions = "@MC_VERSION@", clientSideOnly = true, certificateFingerprint = "@FINGERPRINT@")
public class SkinChangerMod {

public static final String MOD_ID = "skinchanger";
public static final String VERSION = "3.0.1";
public static final String VERSION = "@VERSION@";

// Forge will instantiate this
@Mod.Instance
Expand All @@ -60,11 +62,13 @@ public class SkinChangerMod {
private File modConfigDirectory;

private final SkinChangerStorage skinChangerStorage;
private final ApagogeHandler apagogeHandler;

// When forge creates a new instance of this class we need
// to also build the storage component of the mod.
public SkinChangerMod() {
this.skinChangerStorage = new SkinChangerStorage();
public SkinChangerMod() throws URISyntaxException {
this.skinChangerStorage = new SkinChangerStorage(this);
this.apagogeHandler = new ApagogeHandler(new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI()), "SkinChanger", SkinChangerMod.VERSION);
}

@Mod.EventHandler
Expand All @@ -84,7 +88,23 @@ public void preInit(FMLPreInitializationEvent event) {

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
//MinecraftForge.EVENT_BUS.register(new MainEvents(this));
// Just a few classes, make sure they have the correct signature.
this.apagogeHandler.addValidatorClasses(SkinChangerMod.class,
SkinChangerStorage.class,
SkinCommand.class,
CacheRetriever.class,
ConfigurationHandler.class,
CosmeticFactory.class
);

this.apagogeHandler.addCompletionListener((handler, success) -> {
if (!success) {
System.err.println("Apagoge failed.");
} else {
System.err.println("Apagoge succeeded");
}
});

ClientCommandHandler.instance.registerCommand(new SkinCommand(this));
}

Expand All @@ -94,15 +114,18 @@ public void postInit(FMLPostInitializationEvent event) {

this.cosmeticFactory = new CosmeticFactory(this);

// Hook Resource Reloads
// ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(r -> {
// System.out.println("Resources reloaded");
// });

// This forces our patches to be done NOW!
// This forces our patches to be done as the game loads
new NetworkPlayerInfo((GameProfile) null);
}

@Mod.EventHandler
public void onSignatureViolation(FMLFingerprintViolationEvent event) {
System.err.println("Signature violation detected. Killing updater.");

// Deletes updater & all data under it
this.apagogeHandler.requestKill();
}

/**
* Returns the storage container containing the players custom skin, cape and skin type options
*
Expand All @@ -118,7 +141,7 @@ public SkinChangerStorage getStorage() {
* @return the config handler used by the mod.
*/
public ConfigurationHandler getConfigurationHandler() {
return configurationHandler;
return this.configurationHandler;
}

/**
Expand All @@ -127,18 +150,18 @@ public ConfigurationHandler getConfigurationHandler() {
* @return the cosmetic factory.
*/
public CosmeticFactory getCosmeticFactory() {
return cosmeticFactory;
return this.cosmeticFactory;
}

/**
* Returns the object containing all the smart caching objects.
*
* <p>
* Automatically saves and stores files retrieved from websites or Mojang's database to increase load times.
*
* @return the caching platform used by the mod.
*/
public CacheRetriever getCacheRetriever() {
return cacheRetriever;
return this.cacheRetriever;
}

/**
Expand All @@ -147,7 +170,17 @@ public CacheRetriever getCacheRetriever() {
* @return defaults to the forge/skinchanger directory.
*/
public File getModConfigDirectory() {
return modConfigDirectory;
return this.modConfigDirectory;
}

/**
* Returns the mod updater instance, this may be null if the mod is running
* in a beta environment (if the file hash cannot be checked)
*
* @return the mod updater instance or null if the build is not official.
*/
public ApagogeHandler getApagogeHandler() {
return this.apagogeHandler;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/wtf/boomy/mods/skinchanger/api/SkinAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected final String getUrl(String url) {
HttpURLConnection connection = (HttpURLConnection) new URL(url.replace(" ", "%20")).openConnection();
connection.setRequestMethod("GET");
connection.setUseCaches(false);
connection.addRequestProperty("User-Agent", "Mozilla/5.0 (compatible; SkinChanger; 3.0.1) Chrome/83.0.4103.116");
connection.addRequestProperty("User-Agent", "Mozilla/5.0 (compatible; SkinChanger; @VERSION@) Chrome/83.0.4103.116");
connection.setReadTimeout(15000);
connection.setConnectTimeout(15000);
connection.setDoOutput(true);
Expand Down
54 changes: 31 additions & 23 deletions src/main/java/wtf/boomy/mods/skinchanger/commands/SkinCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

package wtf.boomy.mods.skinchanger.commands;

import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.command.ICommandSender;

import net.minecraft.entity.player.EntityPlayer;
import wtf.boomy.mods.skinchanger.SkinChangerMod;
import wtf.boomy.mods.skinchanger.cosmetic.impl.SkinChangerStorage;
import wtf.boomy.mods.skinchanger.gui.SkinChangerMenu;
Expand Down Expand Up @@ -56,29 +58,29 @@ public List<String> getAliases() {

@Override
public void onCommand(ICommandSender sender, String[] args) {
if (!this.storage.isSkinPatchApplied() && !this.storage.isCapePatchApplied() && !this.storage.isSkinTypePatchApplied()) {
if (args.length > 0 && args[0].equalsIgnoreCase("noconfig")) {
File file = new File(this.mod.getModConfigDirectory(), "asm.txt");
if (file.exists() && !file.delete()) {
sendMessage(ChatColor.RED + "Unable " + ChatColor.GRAY + " to reset your SkinChanger ASM config. Please visit " + ChatColor.AQUA + "https://bot.boomy.wtf/support");
} else {
sendMessage(ChatColor.GRAY + "ASM Config has been deleted. Please restart your game for the changes to go into effect.");
}
return;
}
sendMessage(ChatColor.RED + "No patches have been applied so the mod is disabled. ");
sendMessage("");
sendMessage(ChatColor.GRAY + "Try: ");
sendMessage(ChatColor.GRAY + " 1. Running " + ChatColor.AQUA + "/" + getCommandName() + " noconfig");
sendMessage(ChatColor.GRAY + " 2. Restarting your game.");
sendMessage("");
sendMessage(ChatColor.GRAY + "Please visit " + ChatColor.AQUA + "https://bot.boomy.wtf/support" + ChatColor.GRAY + " for more assistance.");
return;
}
// if (!this.storage.isSkinPatchApplied() && !this.storage.isCapePatchApplied() && !this.storage.isSkinTypePatchApplied()) {
// if (args.length > 0 && args[0].equalsIgnoreCase("noconfig")) {
// File file = new File(this.mod.getModConfigDirectory(), "asm.txt");
//
// if (file.exists() && !file.delete()) {
// sendMessage(ChatColor.RED + "Unable " + ChatColor.GRAY + " to reset your SkinChanger ASM config. Please visit " + ChatColor.AQUA + "https://bot.boomy.wtf/support");
// } else {
// sendMessage(ChatColor.GRAY + "ASM Config has been deleted. Please restart your game for the changes to go into effect.");
// }
//
// return;
// }
//
// sendMessage(ChatColor.RED + "No patches have been applied so the mod is disabled. ");
// sendMessage("");
// sendMessage(ChatColor.GRAY + "Try: ");
// sendMessage(ChatColor.GRAY + " 1. Running " + ChatColor.AQUA + "/" + getCommandName() + " noconfig");
// sendMessage(ChatColor.GRAY + " 2. Restarting your game.");
// sendMessage("");
// sendMessage(ChatColor.GRAY + "Please visit " + ChatColor.AQUA + "https://bot.boomy.wtf/support" + ChatColor.GRAY + " for more assistance.");
//
// return;
// }

// TODO remove this during production.
if (args.length > 0) {
Expand All @@ -91,6 +93,12 @@ public void onCommand(ICommandSender sender, String[] args) {
this.mainMenu = new SkinChangerMenu();

args = new String[0];
} else if (args[0].equalsIgnoreCase("debug")) {
sendMessage("Skin is: " + ((AbstractClientPlayer)sender).getLocationSkin().toString());
sendMessage("Cape is: " + ((AbstractClientPlayer)sender).getLocationCape().toString());
sendMessage("Type is: " + ((AbstractClientPlayer)sender).getSkinType());

return;
}
}

Expand Down
Loading

0 comments on commit b54f98e

Please sign in to comment.