@@ -261,10 +261,6 @@ public void sendBoxMailbox(CommandSender sender, Arguments args) {
261
261
262
262
plugin .mailboxListener .registerRightClickCallback (p , 100 ,
263
263
(Location boxLocation ) -> {
264
- if (boxLocation .equals (toLocationFinal )) {
265
- msg (p , "user.mailbox.same_src_dst" );
266
- return ;
267
- }
268
264
if (!plugin .vaultUtil .enoughMoney (p , plugin .cfg .mailChestFee )) {
269
265
msg (p , "user.mailbox.money_insufficient" );
270
266
return ;
@@ -279,12 +275,14 @@ public void sendBoxMailbox(CommandSender sender, Arguments args) {
279
275
280
276
Inventory fromInventory = ((InventoryHolder ) b .getState ()).getInventory ();
281
277
Inventory toInventory = ((InventoryHolder ) toLocationFinal .getBlock ().getState ()).getInventory ();
282
- ItemStack [] from = fromInventory .getStorageContents ();
278
+ ItemStack [] fromBefore = fromInventory .getStorageContents ();
279
+ ItemStack [] fromAfter = new ItemStack [fromBefore .length ];
280
+ fromInventory .setStorageContents (fromAfter );
283
281
ItemStack [] to = toInventory .getStorageContents ();
284
282
int nextSlot = 0 ;
285
283
boolean itemMoved = false ;
286
- for (int i = 0 ; i < from .length ; i ++) {
287
- if (from [i ] != null && from [i ].getType () != Material .AIR ) {
284
+ for (int i = 0 ; i < fromBefore .length ; i ++) {
285
+ if (fromBefore [i ] != null && fromBefore [i ].getType () != Material .AIR ) {
288
286
while (nextSlot < to .length && to [nextSlot ] != null && to [nextSlot ].getType () != Material .AIR ) {
289
287
nextSlot ++;
290
288
}
@@ -293,16 +291,15 @@ public void sendBoxMailbox(CommandSender sender, Arguments args) {
293
291
if (recpFinal != null ) {
294
292
msg (recpFinal , "user.mailbox.mailbox_no_space" , sender .getName ());
295
293
}
294
+ fromInventory .setStorageContents (fromBefore );
296
295
return ;
297
296
}
298
- to [nextSlot ] = from [i ].clone ();
297
+ to [nextSlot ] = fromBefore [i ].clone ();
299
298
itemMoved = true ;
300
- from [i ] = new ItemStack (Material .AIR );
301
299
nextSlot ++;
302
300
}
303
301
}
304
302
if (itemMoved ) {
305
- fromInventory .setStorageContents (from );
306
303
toInventory .setStorageContents (to );
307
304
msg (sender , "user.mailbox.mail_sent" , toPlayer , (float ) plugin .cfg .mailChestFee );
308
305
if (recpFinal != null ) {
0 commit comments