use of com.bgsoftware.wildchests.objects.containers.LinkedChestsContainer in project WildChests by BG-Software-LLC.
the class WLinkedChest method linkIntoChest.
@Override
public void linkIntoChest(LinkedChest linkedChest) {
if (linkedChest == null) {
if (linkedChestsContainer != null)
linkedChestsContainer.unlinkChest(this);
linkedChestsContainer = null;
saveLinkedChest();
return;
}
LinkedChestsContainer otherContainer = ((WLinkedChest) linkedChest).linkedChestsContainer;
if (otherContainer == null) {
linkedChest.onBreak(new BlockBreakEvent(null, null));
if (linkedChestsContainer == null)
linkedChestsContainer = new LinkedChestsContainer(this);
((WLinkedChest) linkedChest).linkedChestsContainer = linkedChestsContainer;
linkedChestsContainer.linkChest(linkedChest);
} else {
if (otherContainer.isLinkedChest(this))
return;
otherContainer.linkChest(this);
if (linkedChestsContainer != null)
linkedChestsContainer.unlinkChest(this);
linkedChestsContainer = otherContainer;
}
((WLinkedChest) linkedChest).saveLinkedChest();
saveLinkedChest();
}
use of com.bgsoftware.wildchests.objects.containers.LinkedChestsContainer in project WildChests by BG-Software-LLC.
the class WLinkedChest method loadFromData.
public void loadFromData(String serialized, String linkedChest) {
super.loadFromData(serialized);
if (!linkedChest.isEmpty()) {
Location linkedChestLocation = LocationUtils.fromString(linkedChest);
Executor.sync(() -> {
LinkedChest sourceChest = plugin.getChestsManager().getLinkedChest(linkedChestLocation);
if (sourceChest != null) {
if (((WLinkedChest) sourceChest).linkedChestsContainer == null)
((WLinkedChest) sourceChest).linkedChestsContainer = new LinkedChestsContainer(sourceChest);
this.linkedChestsContainer = ((WLinkedChest) sourceChest).linkedChestsContainer;
this.linkedChestsContainer.linkChest(this);
}
}, 1L);
}
}
Aggregations