@@ -51,13 +51,13 @@ public class WarpInventory {
5151
5252 @ Inject
5353 public WarpInventory (
54- WarpService warpService ,
55- Server server ,
56- MiniMessage miniMessage ,
57- WarpTeleportService warpTeleportService ,
58- WarpSettings warpSettings ,
59- Scheduler scheduler ,
60- WarpInventoryConfigService warpInventoryConfigService ) {
54+ WarpService warpService ,
55+ Server server ,
56+ MiniMessage miniMessage ,
57+ WarpTeleportService warpTeleportService ,
58+ WarpSettings warpSettings ,
59+ Scheduler scheduler ,
60+ WarpInventoryConfigService warpInventoryConfigService ) {
6161 this .warpService = warpService ;
6262 this .server = server ;
6363 this .miniMessage = miniMessage ;
@@ -69,23 +69,23 @@ public WarpInventory(
6969
7070 public void open (Player player ) {
7171 this .warpInventoryConfigService .getWarpInventoryData ()
72- .thenAccept (warpData -> {
73- this .scheduler .run (() -> {
74- Gui gui = this .create (player , warpData );
75- gui .open (player );
76- });
77- })
78- .exceptionally (FutureHandler ::handleException );
72+ .thenAccept (warpData -> {
73+ this .scheduler .run (() -> {
74+ Gui gui = this .create (player , warpData );
75+ gui .open (player );
76+ });
77+ })
78+ .exceptionally (FutureHandler ::handleException );
7979 }
8080
8181 private Gui create (Player player , WarpInventoryConfigService .WarpInventoryConfigData warpData ) {
8282 int rows = calculateRowsCount (warpData );
8383
8484 Gui gui = Gui .gui ()
85- .title (this .miniMessage .deserialize (warpData .title ()))
86- .rows (rows )
87- .disableAllInteractions ()
88- .create ();
85+ .title (this .miniMessage .deserialize (warpData .title ()))
86+ .rows (rows )
87+ .disableAllInteractions ()
88+ .create ();
8989
9090 this .createWarpItems (player , warpData , gui );
9191 this .createBorder (warpData , gui );
@@ -133,9 +133,9 @@ private GuiItem createBorderItem(WarpInventoryConfig.BorderSection borderSection
133133
134134 if (!borderSection .lore ().isEmpty ()) {
135135 List <Component > loreComponents = borderSection .lore ()
136- .stream ()
137- .map (entry -> AdventureUtil .resetItalic (this .miniMessage .deserialize (entry )))
138- .toList ();
136+ .stream ()
137+ .map (entry -> AdventureUtil .resetItalic (this .miniMessage .deserialize (entry )))
138+ .toList ();
139139 borderItem .lore (loreComponents );
140140 }
141141
@@ -205,22 +205,22 @@ private BaseItemBuilder createItem(ConfigItem item) {
205205 Component name = AdventureUtil .resetItalic (this .miniMessage .deserialize (item .name ()));
206206
207207 List <Component > lore = item .lore ()
208- .stream ()
209- .map (entry -> AdventureUtil .resetItalic (this .miniMessage .deserialize (entry )))
210- .toList ();
208+ .stream ()
209+ .map (entry -> AdventureUtil .resetItalic (this .miniMessage .deserialize (entry )))
210+ .toList ();
211211
212212 if (item .material () == Material .PLAYER_HEAD && !item .texture ().isEmpty ()) {
213213 return ItemBuilder .skull ()
214- .name (name )
215- .lore (lore )
216- .texture (item .texture ())
217- .glow (item .glow ());
218- }
219-
220- return ItemBuilder .from (item .material ())
221214 .name (name )
222215 .lore (lore )
216+ .texture (item .texture ())
223217 .glow (item .glow ());
218+ }
219+
220+ return ItemBuilder .from (item .material ())
221+ .name (name )
222+ .lore (lore )
223+ .glow (item .glow ());
224224 }
225225
226226 public CompletableFuture <Void > addWarp (Warp warp ) {
@@ -229,28 +229,28 @@ public CompletableFuture<Void> addWarp(Warp warp) {
229229 }
230230
231231 return this .warpInventoryConfigService .getWarpInventoryData ()
232- .thenCompose (warpData -> {
233- int slot = getSlot (warpData );
232+ .thenCompose (warpData -> {
233+ int slot = getSlot (warpData );
234234
235- WarpInventoryItem warpInventoryItem = createWarpInventoryItem (warp , slot );
235+ WarpInventoryItem warpInventoryItem = createWarpInventoryItem (warp , slot );
236236
237- return this .warpInventoryConfigService .addWarpItem (warp .getName (), warpInventoryItem );
238- })
239- .exceptionally (FutureHandler ::handleException );
237+ return this .warpInventoryConfigService .addWarpItem (warp .getName (), warpInventoryItem );
238+ })
239+ .exceptionally (FutureHandler ::handleException );
240240 }
241241
242242 private WarpInventoryItem createWarpInventoryItem (Warp warp , int slot ) {
243243 return WarpInventoryItem .builder ()
244- .warpName (warp .getName ())
245- .warpItem (ConfigItem .builder ()
246- .withName (this .warpSettings .itemNamePrefix () + warp .getName ())
247- .withLore (Collections .singletonList (this .warpSettings .itemLore ()))
248- .withMaterial (this .warpSettings .itemMaterial ())
249- .withTexture (this .warpSettings .itemTexture ())
250- .withSlot (slot )
251- .withGlow (true )
252- .build ())
253- .build ();
244+ .warpName (warp .getName ())
245+ .warpItem (ConfigItem .builder ()
246+ .withName (this .warpSettings .itemNamePrefix () + warp .getName ())
247+ .withLore (Collections .singletonList (this .warpSettings .itemLore ()))
248+ .withMaterial (this .warpSettings .itemMaterial ())
249+ .withTexture (this .warpSettings .itemTexture ())
250+ .withSlot (slot )
251+ .withGlow (true )
252+ .build ())
253+ .build ();
254254 }
255255
256256 private int getSlot (WarpInventoryConfigService .WarpInventoryConfigData warpData ) {
@@ -274,21 +274,22 @@ public CompletableFuture<Void> removeWarp(String warpName) {
274274 }
275275
276276 return this .warpInventoryConfigService .removeWarpItem (warpName )
277- .thenCompose (removed -> {
278- if (removed != null ) {
279- return this .shiftWarpItems (removed , items );
280- }
281- return CompletableFuture .completedFuture (null );
282- });
277+ .thenCompose (removed -> {
278+ if (removed != null ) {
279+ return this .shiftWarpItems (removed , items )
280+ .thenCompose (v -> this .warpInventoryConfigService .save ());
281+ }
282+ return CompletableFuture .completedFuture (null );
283+ });
283284 }
284285
285286 private CompletableFuture <Void > shiftWarpItems (WarpInventoryItem removed , Map <String , WarpInventoryItem > items ) {
286287 int removedSlot = removed .warpItem ().slot ;
287288
288289 List <WarpInventoryItem > itemsToShift = items .values ().stream ()
289- .filter (item -> item .warpItem ().slot > removedSlot )
290- .sorted (Comparator .comparingInt (item -> item .warpItem ().slot ))
291- .toList ();
290+ .filter (item -> item .warpItem ().slot > removedSlot )
291+ .sorted (Comparator .comparingInt (item -> item .warpItem ().slot ))
292+ .toList ();
292293
293294 int currentShift = removedSlot ;
294295 for (WarpInventoryItem item : itemsToShift ) {
0 commit comments