Skip to content

Commit

Permalink
Fix keybind commands
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed Nov 1, 2023
1 parent 539b426 commit cf3ec55
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 deletions core/src/mindustry/client/utils/Migrations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import mindustry.type.*
/** Allows for simple migrations between versions of the client. */
class Migrations {
fun runMigrations() {
val functions = this::class.java.declaredMethods // Cached function list
val functions = this::class.java.declaredMethods // Cached function list. Using kotlin reflection to find functions is extremely slow.
var migration = settings.getInt("foomigration", 1) // Starts at 1
while (true) {
val migrateFun = functions.find { it.name == "migration$migration" } ?: break // Find next migration or break
Expand All @@ -27,15 +27,6 @@ class Migrations {
}

private fun migration1() { // All of the migrations from before the existence of the migration system
// Old settings that no longer exist
settings.remove("drawhitboxes")
settings.remove("signmessages")
settings.remove("firescl")
settings.remove("effectscl")
settings.remove("commandwarnings")
settings.remove("nodeconfigs")
settings.remove("attemwarfarewhisper")

// Various setting names and formats have changed
if (settings.has("gameovertext")) {
if (settings.getString("gameovertext").isNotBlank()) settings.put("gamewintext", settings.getString("gameovertext"))
Expand All @@ -49,9 +40,18 @@ class Migrations {
settings.put("hitboxopacity", 30)
UnitType.hitboxAlpha = settings.getInt("hitboxopacity") / 100f
}

// Old settings that no longer exist
settings.remove("drawhitboxes")
settings.remove("signmessages")
settings.remove("firescl")
settings.remove("effectscl")
settings.remove("commandwarnings")
settings.remove("nodeconfigs")
settings.remove("attemwarfarewhisper")
}

private fun migration2() { // Lowercased the pingExecutorThreads setting name1
private fun migration2() { // Lowercased the pingExecutorThreads setting name
if (!settings.has("pingExecutorThreads")) return
settings.put("pingexecutorthreads", settings.getInt("pingExecutorThreads"))
settings.remove("pingExecutorThreads")
Expand Down
10 changes: 5 additions & 5 deletions core/src/mindustry/input/DesktopInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ private enum JSBindingOption {
none(() -> true, "keybind1command", "No JS configured for keybind @, go to client settings to add a script to run", false),
;

public Boolp check;
public String settingsKey;
public String message;
public boolean runIfOthersRan;
public final Boolp check;
public final String settingsKey;
public final String message;
public final boolean runIfOthersRan;

JSBindingOption(Boolp check, String settingsKey, String message, boolean runIfOthersRan){
this.check = check;
Expand Down Expand Up @@ -327,7 +327,7 @@ public void update(){
boolean ran = false;
for(var opt : JSBindingOption.values()){
if(opt.check.get() && (opt.runIfOthersRan || !ran)){
if(Core.settings.getString(opt.settingsKey, "") != ""){
if(!settings.getString(opt.settingsKey, "").isEmpty()){
ChatFragment.handleClientCommand(Core.settings.getString(opt.settingsKey, ""));
ran = true;
} else {
Expand Down

0 comments on commit cf3ec55

Please sign in to comment.