Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Nov 25, 2024
2 parents 388d944 + eda4f67 commit a1839a7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
6 changes: 0 additions & 6 deletions src/main/java/com/wasteofplastic/invswitcher/InvSwitcher.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.wasteofplastic.invswitcher;


import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;

import com.wasteofplastic.invswitcher.listeners.PlayerListener;
Expand All @@ -26,9 +23,6 @@
*/
public class InvSwitcher extends Addon {

protected static final List<Material> MAT = Arrays.stream(Material.values())
.filter(m -> !m.name().startsWith("LEGACY")).toList();

private Store store;

private Settings settings;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.wasteofplastic.invswitcher;


import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.addons.Pladdon;

public class InvSwitcherPladdon extends Pladdon {

private Addon addon;

@Override
public Addon getAddon() {
if (addon == null) {
addon = new InvSwitcher();
}
return addon;
}
}
9 changes: 5 additions & 4 deletions src/main/java/com/wasteofplastic/invswitcher/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.Statistic;
import org.bukkit.World;
import org.bukkit.advancement.Advancement;
Expand Down Expand Up @@ -275,26 +276,26 @@ private CompletableFuture<InventoryStorage> saveStats(InventoryStorage store, Pl

private void saveStatistics(CompletableFuture<InventoryStorage> result, InventoryStorage store, Player player,
String worldName) {
Arrays.stream(Statistic.values()).forEach(s -> {
Registry.STATISTIC.forEach(s -> {
Map<Material, Integer> map;
Map<EntityType, Integer> entMap;
switch (s.getType()) {
case BLOCK -> {
map = InvSwitcher.MAT.stream().filter(Material::isBlock).filter(m -> player.getStatistic(s, m) > 0)
map = Registry.MATERIAL.stream().filter(Material::isBlock).filter(m -> player.getStatistic(s, m) > 0)
.collect(Collectors.toMap(k -> k, v -> player.getStatistic(s, v)));
if (!map.isEmpty()) {
store.getBlockStats(worldName).put(s, map);
}
}
case ITEM -> {
map = InvSwitcher.MAT.stream().filter(Material::isItem).filter(m -> player.getStatistic(s, m) > 0)
map = Registry.MATERIAL.stream().filter(Material::isItem).filter(m -> player.getStatistic(s, m) > 0)
.collect(Collectors.toMap(k -> k, v -> player.getStatistic(s, v)));
if (!map.isEmpty()) {
store.getItemStats(worldName).put(s, map);
}
}
case ENTITY -> {
entMap = Arrays.stream(EntityType.values()).filter(EntityType::isAlive)
entMap = Registry.ENTITY_TYPE.stream().filter(EntityType::isAlive)
.filter(m -> player.getStatistic(s, m) > 0)
.collect(Collectors.toMap(k -> k, v -> player.getStatistic(s, v)));
if (!entMap.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: InvSwitcher
main: com.wasteofplastic.invswitcher.InvSwitcher
version: ${version}${build.number}
api-version: 2.7.1
api-version: 3.0.0

authors: tastybento

Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: BentoBox-InvSwitcher
main: com.wasteofplastic.invswitcher.InvSwitcherPladdon
version: ${project.version}${build.number}
api-version: "1.21"

authors: [tastybento]
contributors: ["The BentoBoxWorld Community"]
website: https://bentobox.world
description: ${project.description}

0 comments on commit a1839a7

Please sign in to comment.