27
27
@ NoArgsConstructor (access = AccessLevel .PRIVATE )
28
28
public class QuickSlots {
29
29
30
- public static final int QUICKSLOTS_N = 9 ;
30
+ public static final int SLOTS_AMOUNT = 9 ;
31
31
32
- public static final Recording [] QUICKSLOTS = new Recording [QUICKSLOTS_N ];
33
- public static final String [] QUICKSLOT_FILE_NAMES = {
32
+ public static final Recording [] SLOTS = new Recording [SLOTS_AMOUNT ];
33
+ public static final String [] SLOT_FILE_NAMES = {
34
34
"quickslot_1.rec" ,
35
35
"quickslot_2.rec" ,
36
36
"quickslot_3.rec" ,
@@ -43,26 +43,26 @@ public class QuickSlots {
43
43
};
44
44
45
45
// KeyBinding State
46
- private static final int [] storeCooldowns = new int [QUICKSLOTS_N ];
47
- private static final int [] loadCooldowns = new int [QUICKSLOTS_N ];
48
- private static final boolean [] CTRLPressed = new boolean [QUICKSLOTS_N ];
49
- private static final boolean [] ALTPressed = new boolean [QUICKSLOTS_N ];
46
+ private static final int [] storeCooldowns = new int [SLOTS_AMOUNT ];
47
+ private static final int [] loadCooldowns = new int [SLOTS_AMOUNT ];
48
+ private static final boolean [] CTRLPressed = new boolean [SLOTS_AMOUNT ];
49
+ private static final boolean [] ALTPressed = new boolean [SLOTS_AMOUNT ];
50
50
private static final int COOLDOWN = 5 ;
51
51
52
52
private static void store (int slot , Recording recording ) {
53
- if (slot < 0 || slot >= QUICKSLOTS_N ) {
53
+ if (slot < 0 || slot >= SLOTS_AMOUNT ) {
54
54
return ;
55
55
}
56
56
57
- QUICKSLOTS [slot ] = recording ;
58
- NativeImageBackedTexture texture = recording .thumbnail != null ? new NativeImageBackedTexture (() -> QUICKSLOT_FILE_NAMES [slot ], recording .thumbnail .toNativeImage ()) : null ;
57
+ SLOTS [slot ] = recording ;
58
+ NativeImageBackedTexture texture = recording .thumbnail != null ? new NativeImageBackedTexture (() -> SLOT_FILE_NAMES [slot ], recording .thumbnail .toNativeImage ()) : null ;
59
59
updateQuickSlotTexture (slot , texture );
60
60
// I assume that this doesn't fail, and therefore I don't check a return value i created to check this fails ...
61
- IOHelpers .storeRecordingFile (QUICKSLOTS [slot ], new File (PLAYERAUTOMA_QUICKSLOT_PATH ), QUICKSLOT_FILE_NAMES [slot ], IOHelpers .RecordingFileTypes .REC , true );
61
+ IOHelpers .storeRecordingFile (SLOTS [slot ], new File (PLAYERAUTOMA_QUICKSLOT_PATH ), SLOT_FILE_NAMES [slot ], IOHelpers .RecordingFileTypes .REC , true );
62
62
}
63
63
64
64
private static Recording load (int slot ) {
65
- return QUICKSLOTS [slot ];
65
+ return SLOTS [slot ];
66
66
}
67
67
68
68
public static final Identifier [] THUMBNAIL_IDENTIFIER ;
@@ -81,7 +81,7 @@ private static Recording load(int slot) {
81
81
Identifier .of (PlayerautomaClient .MOD_ID , "quickslot_8" ),
82
82
Identifier .of (PlayerautomaClient .MOD_ID , "quickslot_9" ),
83
83
};
84
- Arrays .fill (QUICKSLOTS , new Recording (null ));
84
+ Arrays .fill (SLOTS , new Recording (null ));
85
85
Arrays .fill (ALTPressed , false );
86
86
Arrays .fill (CTRLPressed , false );
87
87
Arrays .fill (storeCooldowns , 0 );
@@ -90,19 +90,19 @@ private static Recording load(int slot) {
90
90
91
91
public static void clearQuickSlot () {
92
92
ClientHelpers .writeToActionBar (Text .translatable ("playerautoma.messages.clearedAllQuickSlot" ));
93
- for (int i = 0 ; i < QUICKSLOTS_N ; i ++) {
94
- QUICKSLOTS [i ].clear ();
93
+ for (int i = 0 ; i < SLOTS_AMOUNT ; i ++) {
94
+ SLOTS [i ].clear ();
95
95
// Clear file and thumbnail texture
96
- store (i , QUICKSLOTS [i ]);
96
+ store (i , SLOTS [i ]);
97
97
ClientHelpers .writeToActionBar (Text .translatable ("playerautoma.messages.clearedAllQuickSlot" ));
98
98
}
99
99
}
100
100
101
101
public static void clearQuickSlot (int slot ) {
102
- if (slot >= 0 && slot <= QUICKSLOTS_N ) {
103
- QUICKSLOTS [slot ].clear ();
102
+ if (slot >= 0 && slot <= SLOTS_AMOUNT ) {
103
+ SLOTS [slot ].clear ();
104
104
// Clear file and thumbnail texture
105
- store (slot , QUICKSLOTS [slot ]);
105
+ store (slot , SLOTS [slot ]);
106
106
ClientHelpers .writeToActionBar (Text .translatable ("playerautoma.messages.clearedOneQuickSlot" ).append (" " + (slot + 1 )));
107
107
}
108
108
}
@@ -135,7 +135,7 @@ private static void consumeKeyPress(KeyBinding key, int limit) {
135
135
}
136
136
137
137
public static void updateQuickSlotTexture (int slot , NativeImageBackedTexture texture ) {
138
- if (slot < 0 || slot >= QUICKSLOTS_N ) {
138
+ if (slot < 0 || slot >= SLOTS_AMOUNT ) {
139
139
return ;
140
140
}
141
141
@@ -147,7 +147,7 @@ public static void updateQuickSlotTexture(int slot, NativeImageBackedTexture tex
147
147
}
148
148
149
149
public static void loadRecording (int slot ) {
150
- if (slot < 0 || slot >= QUICKSLOTS_N ) {
150
+ if (slot < 0 || slot >= SLOTS_AMOUNT ) {
151
151
return ;
152
152
}
153
153
@@ -161,45 +161,45 @@ public static void loadRecording(int slot) {
161
161
return ;
162
162
}
163
163
164
- PlayerRecorder .record = r ;
164
+ PlayerRecorder .recording = r ;
165
165
// Destroy old texture, register new one if present
166
166
MinecraftClient .getInstance ().getTextureManager ().destroyTexture (PlayerRecorder .THUMBNAIL_TEXTURE_IDENTIFIER );
167
167
if (r .thumbnail != null ) {
168
- PlayerRecorder .thumbnailTexture = new NativeImageBackedTexture (() -> QUICKSLOT_FILE_NAMES [slot ], r .thumbnail .toNativeImage ());
168
+ PlayerRecorder .thumbnailTexture = new NativeImageBackedTexture (() -> SLOT_FILE_NAMES [slot ], r .thumbnail .toNativeImage ());
169
169
MinecraftClient .getInstance ().getTextureManager ().registerTexture (PlayerRecorder .THUMBNAIL_TEXTURE_IDENTIFIER , PlayerRecorder .thumbnailTexture );
170
170
}
171
171
172
172
ClientHelpers .writeToActionBar (Text .translatable ("playerautoma.messages.loadQuickslot" ).append (Text .of ("" + (slot + 1 ))));
173
173
}
174
174
175
175
public static void storeRecording (int slot ) {
176
- if (slot < 0 || slot >= QUICKSLOTS_N ) {
176
+ if (slot < 0 || slot >= SLOTS_AMOUNT ) {
177
177
return ;
178
178
}
179
179
180
180
// Check if store operation can be done
181
181
if (PlayerRecorder .state != PlayerRecorder .State .IDLE ) {
182
182
ClientHelpers .writeToActionBar (Text .translatable ("playerautoma.messages.error.cannotStoreDueToState" ));
183
183
return ;
184
- } else if (PlayerRecorder .record == null || PlayerRecorder .record .isEmpty ()) {
184
+ } else if (PlayerRecorder .recording == null || PlayerRecorder .recording .isEmpty ()) {
185
185
ClientHelpers .writeToActionBar (Text .translatable ("playerautoma.messages.error.cannotStoreEmpty" ));
186
186
return ;
187
187
}
188
188
189
189
// Store quickslots to file to be persistent in store
190
- store (slot , PlayerRecorder .record .copy ());
190
+ store (slot , PlayerRecorder .recording .copy ());
191
191
ClientHelpers .writeToActionBar (Text .translatable ("playerautoma.messages.storeQuickslot" ).append (Text .of ("" + (slot + 1 ))));
192
192
}
193
193
194
194
@ SuppressWarnings ("java:S3776" )
195
195
public static void register () {
196
196
// Load persistent quickslots.
197
- for (int i = 0 ; i < QUICKSLOTS_N ; i ++) {
198
- Recording r = IOHelpers .loadRecordingFile (new File (PLAYERAUTOMA_QUICKSLOT_PATH ), new File (QUICKSLOT_FILE_NAMES [i ]));
199
- QUICKSLOTS [i ] = r ;
197
+ for (int i = 0 ; i < SLOTS_AMOUNT ; i ++) {
198
+ Recording r = IOHelpers .loadRecordingFile (new File (PLAYERAUTOMA_QUICKSLOT_PATH ), new File (SLOT_FILE_NAMES [i ]));
199
+ SLOTS [i ] = r ;
200
200
if (r .thumbnail != null ) {
201
201
int finalI = i ;
202
- MinecraftClient .getInstance ().getTextureManager ().registerTexture (THUMBNAIL_IDENTIFIER [i ], new NativeImageBackedTexture (() -> QUICKSLOT_FILE_NAMES [finalI ], r .thumbnail .toNativeImage ()));
202
+ MinecraftClient .getInstance ().getTextureManager ().registerTexture (THUMBNAIL_IDENTIFIER [i ], new NativeImageBackedTexture (() -> SLOT_FILE_NAMES [finalI ], r .thumbnail .toNativeImage ()));
203
203
}
204
204
}
205
205
@@ -245,11 +245,11 @@ public static void register() {
245
245
});
246
246
}
247
247
248
- private static boolean CTRLPressed (long handle ) {
248
+ private static boolean CTRLPressed (long handle ) { // NOSONAR
249
249
return InputUtil .isKeyPressed (handle , GLFW .GLFW_KEY_LEFT_CONTROL ) || InputUtil .isKeyPressed (handle , GLFW .GLFW_KEY_RIGHT_CONTROL );
250
250
}
251
251
252
- private static boolean ALTPressed (long handle ) {
252
+ private static boolean ALTPressed (long handle ) { // NOSONAR
253
253
return InputUtil .isKeyPressed (handle , GLFW .GLFW_KEY_LEFT_ALT ) || InputUtil .isKeyPressed (handle , GLFW .GLFW_KEY_RIGHT_ALT );
254
254
}
255
255
}
0 commit comments