Skip to content

Commit

Permalink
1.5.62
Browse files Browse the repository at this point in the history
Exposed ButtonManagerMethods#keys
You should not override BlobInventory#loadDefaultButtons since from now on all buttons will be loaded by default.
  • Loading branch information
anjoismysign committed Nov 27, 2022
1 parent d6d90e3 commit f134455
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public Set<Integer> get(String key) {
return getStringKeys().get(key);
}

@Override
public Collection<String> keys() {
return getStringKeys().keySet();
}

@Override
public ItemStack get(int key) {
return getIntegerKeys().get(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public BlobInventory(File file) {
public BlobInventory() {
}

public void addDefaultButtons(String key) {
public void addDefaultButton(String key) {
for (Integer i : getSlots(key)) {
addDefaultButton(key, getButton(i));
break;
Expand All @@ -108,6 +108,9 @@ public void addDefaultButtons(String key) {

public void loadDefaultButtons() {
setDefaultButtons(new HashMap<>());
getKeys().forEach(key -> {
addDefaultButton(key);
});
}

public void addDefaultButton(String name, ItemStack item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public interface ButtonManagerMethods {
Collection<ItemStack> buttons();

boolean add(ConfigurationSection section);

Collection<String> keys();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.bukkit.inventory.ItemStack;

import java.util.Collection;
import java.util.Set;

public abstract class InventoryBuilder {
Expand Down Expand Up @@ -40,4 +41,8 @@ public Set<Integer> getSlots(String key) {
public ItemStack getButton(int slot) {
return buttonManager.get(slot);
}

public Collection<String> getKeys() {
return buttonManager.keys();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ public VariableSelector(BlobInventory blobInventory, UUID builderId,
loadPage(page, false);
}

@Override
public void loadDefaultButtons() {
setDefaultButtons(new HashMap<>());
}

public void loadPage(int page, boolean refill) {
if (page < 1)
return;
Expand Down

0 comments on commit f134455

Please sign in to comment.