Skip to content

Commit

Permalink
Fixed a casting issue when using /chests link on non-linked chests
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Feb 4, 2022
1 parent be68c2c commit 975f48d
Showing 1 changed file with 5 additions and 2 deletions.
@@ -1,5 +1,6 @@
package com.bgsoftware.wildchests.command.commands;

import com.bgsoftware.wildchests.api.objects.chests.Chest;
import com.bgsoftware.wildchests.utils.Executor;
import com.bgsoftware.wildchests.utils.LinkedChestInteractEvent;
import com.bgsoftware.wildchests.Locale;
Expand Down Expand Up @@ -83,13 +84,15 @@ public void perform(WildChestsPlugin plugin, CommandSender sender, String[] args
return;
}

LinkedChest linkedChest = plugin.getChestsManager().getLinkedChest(targetBlock.getLocation());
Chest chest = plugin.getChestsManager().getChest(targetBlock.getLocation());

if(linkedChest == null){
if(!(chest instanceof LinkedChest)){
Locale.NOT_LINKED_CHEST.send(player);
return;
}

LinkedChest linkedChest = (LinkedChest) chest;

if(players.containsKey(player.getUniqueId())){
LinkedChest originalChest = plugin.getChestsManager().getLinkedChest(players.get(player.getUniqueId()));
players.remove(player.getUniqueId());
Expand Down

0 comments on commit 975f48d

Please sign in to comment.