├── MainActivity.java ├── ModPlayerprefs.java ├── README.md └── ModPlayerprefs.smali /MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.platinmods; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.os.Bundle; 6 | 7 | public class MainActivity extends AppCompatActivity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | 14 | ModPlayerprefs.Modded(this.getBaseContext()); 15 | } 16 | } -------------------------------------------------------------------------------- /ModPlayerprefs.java: -------------------------------------------------------------------------------- 1 | package com.platinmods; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.Context; 5 | import android.content.SharedPreferences.Editor; 6 | import java.util.concurrent.atomic.AtomicReference; 7 | 8 | public class ModPlayerprefs { 9 | 10 | // Located Playerprefs = PackageName + Playerprefs 11 | 12 | // PackageName: com.zala.game.defense.heroes.td 13 | 14 | // Type Playerprefs: 15 | // PlayerPrefsX = v2.playerprefs 16 | // PlayerPrefs = playerprefs 17 | 18 | // Final Located Playerprefs = com.zala.game.defense.heroes.td.v2.playerprefs 19 | private static final String Located_Playerprefs = "com.zala.game.defense.heroes.td.v2.playerprefs"; 20 | 21 | @SuppressLint("CommitPrefEdits") 22 | public static void Modded(Context context) { 23 | @SuppressLint("CommitPrefEdits") AtomicReference Mod; 24 | Mod = new AtomicReference<>(context.getSharedPreferences(Located_Playerprefs, 0).edit()); 25 | Mod.get().putInt("totalGem", 99999999); 26 | Mod.get().putInt("totalSoulStone", 88888888); 27 | Mod.get().putInt("totalCoin", 77777777); 28 | Mod.get().putInt("totalKeySummon", 66666666); 29 | Mod.get().putInt("totalPointTalent", 55555555); 30 | Mod.get().putInt("totalTicketRaid", 44444444); 31 | Mod.get().putInt("totalEnergy", 33333333); 32 | Mod.get().putInt("totalBookSkills", 22222222); 33 | Mod.get().apply(); 34 | } 35 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # How to Mod PlayerPrefs of Unity Games (including IL2CPP) 2 | 3 | # Q & A 4 | - Q: What is PlayerPrefs in Unity Games? 5 | - A: `PlayerPrefs` is a class that stores Player preferences between game sessions. It can store string, float and integer values into the user’s platform registry. 6 | 7 | - Q: Where is PlayerPrefs stored in? 8 | - A: On Android, PlayerPrefs are stored in `/data/data/pkg-name/shared_prefs/pkg-name.v2.playerprefs.xml` or `/data/data/pkg-name/shared_prefs/pkg-name.playerprefs.xml` 9 | 10 | - Q: How to make it works in the mods? 11 | - A: what you have to do is build the source code with Android Studio to get the smali files then call that smali file in `OnCreate` of Launch Activity Smali Games. but make sure the path of PlayerPrefs games is correct. 12 | 13 | 14 | # Example: 15 | - As an example you can use this game **[Defense Heroes](https://play.google.com/store/apps/details?id=com.zala.game.defense.heroes.td)** 16 | 17 | - Example Code: 18 | ```java 19 | package com.platinmods; 20 | 21 | import android.annotation.SuppressLint; 22 | import android.content.Context; 23 | import android.content.SharedPreferences.Editor; 24 | import java.util.concurrent.atomic.AtomicReference; 25 | 26 | public class ModPlayerprefs { 27 | 28 | // Located Playerprefs = PackageName + Playerprefs 29 | 30 | // PackageName: com.zala.game.defense.heroes.td 31 | 32 | // Type Playerprefs: 33 | // PlayerPrefsX = v2.playerprefs 34 | // PlayerPrefs = playerprefs 35 | 36 | // Final Located Playerprefs = com.zala.game.defense.heroes.td.v2.playerprefs 37 | private static final String Located_Playerprefs = "com.zala.game.defense.heroes.td.v2.playerprefs"; 38 | 39 | @SuppressLint("CommitPrefEdits") 40 | public static void Modded(Context context) { 41 | @SuppressLint("CommitPrefEdits") AtomicReference Mod; 42 | Mod = new AtomicReference<>(context.getSharedPreferences(Located_Playerprefs, 0).edit()); 43 | Mod.get().putInt("totalGem", 99999999); 44 | Mod.get().putInt("totalSoulStone", 88888888); 45 | Mod.get().putInt("totalCoin", 77777777); 46 | Mod.get().putInt("totalKeySummon", 66666666); 47 | Mod.get().putInt("totalPointTalent", 55555555); 48 | Mod.get().putInt("totalTicketRaid", 44444444); 49 | Mod.get().putInt("totalEnergy", 33333333); 50 | Mod.get().putInt("totalBookSkills", 22222222); 51 | Mod.get().apply(); 52 | } 53 | } 54 | ``` 55 | 56 | # How to call the smali file into your mods 57 | - Copy and Place the smali files that you get from Android Studio 58 | - Then call the file with this smali code 59 | ```smali 60 | invoke-static {p0}, Lcom/platinmods/ModPlayerprefs;->Modded(Landroid/content/Context;)V 61 | ``` 62 | -------------------------------------------------------------------------------- /ModPlayerprefs.smali: -------------------------------------------------------------------------------- 1 | .class public Lcom/platinmods/ModPlayerprefs; 2 | .super Ljava/lang/Object; 3 | .source "ModPlayerprefs.java" 4 | 5 | 6 | # static fields 7 | .field private static final Located_Playerprefs:Ljava/lang/String; = "com.zala.game.defense.heroes.td.v2.playerprefs" 8 | 9 | 10 | # direct methods 11 | .method public constructor ()V 12 | .locals 0 13 | 14 | .line 8 15 | invoke-direct {p0}, Ljava/lang/Object;->()V 16 | 17 | return-void 18 | .end method 19 | 20 | .method public static Modded(Landroid/content/Context;)V 21 | .locals 4 22 | .param p0, "context" # Landroid/content/Context; 23 | .annotation system Ldalvik/annotation/MethodParameters; 24 | accessFlags = { 25 | 0x0 26 | } 27 | names = { 28 | "context" 29 | } 30 | .end annotation 31 | 32 | .line 24 33 | new-instance v0, Ljava/util/concurrent/atomic/AtomicReference; 34 | 35 | const-string v1, "com.zala.game.defense.heroes.td.v2.playerprefs" 36 | 37 | const/4 v2, 0x0 38 | 39 | invoke-virtual {p0, v1, v2}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences; 40 | 41 | move-result-object v1 42 | 43 | invoke-interface {v1}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; 44 | 45 | move-result-object v1 46 | 47 | invoke-direct {v0, v1}, Ljava/util/concurrent/atomic/AtomicReference;->(Ljava/lang/Object;)V 48 | 49 | .line 25 50 | .local v0, "Mod":Ljava/util/concurrent/atomic/AtomicReference;, "Ljava/util/concurrent/atomic/AtomicReference;" 51 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 52 | 53 | move-result-object v1 54 | 55 | check-cast v1, Landroid/content/SharedPreferences$Editor; 56 | 57 | const-string v2, "totalGem" 58 | 59 | const v3, 0x5f5e0ff 60 | 61 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 62 | 63 | .line 26 64 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 65 | 66 | move-result-object v1 67 | 68 | check-cast v1, Landroid/content/SharedPreferences$Editor; 69 | 70 | const-string v2, "totalSoulStone" 71 | 72 | const v3, 0x54c5638 73 | 74 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 75 | 76 | .line 27 77 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 78 | 79 | move-result-object v1 80 | 81 | check-cast v1, Landroid/content/SharedPreferences$Editor; 82 | 83 | const-string v2, "totalCoin" 84 | 85 | const v3, 0x4a2cb71 86 | 87 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 88 | 89 | .line 28 90 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 91 | 92 | move-result-object v1 93 | 94 | check-cast v1, Landroid/content/SharedPreferences$Editor; 95 | 96 | const-string v2, "totalKeySummon" 97 | 98 | const v3, 0x3f940aa 99 | 100 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 101 | 102 | .line 29 103 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 104 | 105 | move-result-object v1 106 | 107 | check-cast v1, Landroid/content/SharedPreferences$Editor; 108 | 109 | const-string v2, "totalPointTalent" 110 | 111 | const v3, 0x34fb5e3 112 | 113 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 114 | 115 | .line 30 116 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 117 | 118 | move-result-object v1 119 | 120 | check-cast v1, Landroid/content/SharedPreferences$Editor; 121 | 122 | const-string v2, "totalTicketRaid" 123 | 124 | const v3, 0x2a62b1c 125 | 126 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 127 | 128 | .line 31 129 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 130 | 131 | move-result-object v1 132 | 133 | check-cast v1, Landroid/content/SharedPreferences$Editor; 134 | 135 | const-string v2, "totalEnergy" 136 | 137 | const v3, 0x1fca055 138 | 139 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 140 | 141 | .line 32 142 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 143 | 144 | move-result-object v1 145 | 146 | check-cast v1, Landroid/content/SharedPreferences$Editor; 147 | 148 | const-string v2, "totalBookSkills" 149 | 150 | const v3, 0x153158e 151 | 152 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 153 | 154 | .line 33 155 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 156 | 157 | move-result-object v1 158 | 159 | check-cast v1, Landroid/content/SharedPreferences$Editor; 160 | 161 | const-string v2, "totalCoinPVP" 162 | 163 | const v3, 0x153158e 164 | 165 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 166 | 167 | .line 34 168 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 169 | 170 | move-result-object v1 171 | 172 | check-cast v1, Landroid/content/SharedPreferences$Editor; 173 | 174 | const-string v2, "totalStoneCraft" 175 | 176 | const v3, 0x153158e 177 | 178 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 179 | 180 | .line 35 181 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 182 | 183 | move-result-object v1 184 | 185 | check-cast v1, Landroid/content/SharedPreferences$Editor; 186 | 187 | const-string v2, "totalTicketLuckyWheel" 188 | 189 | const v3, 0x153158e 190 | 191 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 192 | 193 | .line 36 194 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 195 | 196 | move-result-object v1 197 | 198 | check-cast v1, Landroid/content/SharedPreferences$Editor; 199 | 200 | const-string v2, "totalTicketRaid" 201 | 202 | const v3, 0x153158e 203 | 204 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 205 | 206 | .line 37 207 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 208 | 209 | move-result-object v1 210 | 211 | check-cast v1, Landroid/content/SharedPreferences$Editor; 212 | 213 | const-string v2, "totalMedal" 214 | 215 | const v3, 0x153158e 216 | 217 | invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putInt(Ljava/lang/String;I)Landroid/content/SharedPreferences$Editor; 218 | 219 | .line 38 220 | invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; 221 | 222 | move-result-object v1 223 | 224 | check-cast v1, Landroid/content/SharedPreferences$Editor; 225 | 226 | invoke-interface {v1}, Landroid/content/SharedPreferences$Editor;->apply()V 227 | 228 | .line 39 229 | return-void 230 | .end method 231 | --------------------------------------------------------------------------------