Skip to content

Commit

Permalink
RefractingLens, ExpCollector, Tiers!
Browse files Browse the repository at this point in the history
  • Loading branch information
Sefiraat committed Nov 8, 2021
1 parent 182bd06 commit 7e41116
Show file tree
Hide file tree
Showing 24 changed files with 493 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.github.sefiraat.crystamaehistoria.slimefun.Materials;
import io.github.sefiraat.crystamaehistoria.slimefun.Mechanisms;
import io.github.sefiraat.crystamaehistoria.slimefun.Tools;
import io.github.sefiraat.crystamaehistoria.stories.StoriedBlockDefinition;
import io.github.sefiraat.crystamaehistoria.stories.BlockDefinition;
import io.github.sefiraat.crystamaehistoria.stories.StoriesManager;
import io.github.sefiraat.crystamaehistoria.utils.CrystaTag;
import io.github.sefiraat.crystamaehistoria.utils.PlayerStatUtils;
Expand Down Expand Up @@ -182,7 +182,7 @@ private void setupBstats() {

AdvancedPie storiesChronicled = new AdvancedPie("stories_chronicled", () -> {
Map<String, Integer> values = new HashMap<>();
for (StoriedBlockDefinition definition : CrystamaeHistoria.getStoriesManager().getStoriedBlockDefinitionMap().values()) {
for (BlockDefinition definition : CrystamaeHistoria.getStoriesManager().getBlockDefinitionMap().values()) {
int timesChronicled = 0;
for (String string : CrystamaeHistoria.getConfigManager().getPlayerStats().getKeys(false)) {
UUID uuid = UUID.fromString(string);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public ListenerManager() {
addListener(new CrystalBreakListener());
addListener(new BlockRemovalListener());
addListener(new MaintenanceListener());
addListener(new RefractingLensListener());
}

private void addListener(Listener listener) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package io.github.sefiraat.crystamaehistoria.listeners;

import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.ExpCollector;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.LiquefactionBasin;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.LiquefactionBasinCache;
import io.github.sefiraat.crystamaehistoria.slimefun.tools.RefactingLens;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryType;
import io.github.sefiraat.crystamaehistoria.utils.theme.ThemeType;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TextComponent.Builder;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

import java.util.Map;

public class RefractingLensListener implements Listener {

@EventHandler
public void onInteract(PlayerInteractEvent e) {
final Player player = e.getPlayer();
final SlimefunItem slimefunItem = SlimefunItem.getByItem(player.getInventory().getItemInMainHand());
final Block block = e.getClickedBlock();
if (block != null
&& e.getAction() == Action.RIGHT_CLICK_BLOCK
&& slimefunItem instanceof RefactingLens
) {
e.setCancelled(true);
SlimefunItem item = BlockStorage.check(block);
if (item instanceof LiquefactionBasin) {
liquefactionBasin(player, item, block);
} else if (item instanceof ExpCollector) {
expCollector(player, item, block);
}
}
}

private void liquefactionBasin(Player player, SlimefunItem blockItem, Block clickedBlock) {
final LiquefactionBasin basin = (LiquefactionBasin) blockItem;
final LiquefactionBasinCache cache = basin.getCacheMap().get(clickedBlock.getLocation());
final Builder component = Component.text();
boolean first = true;
for (Map.Entry<StoryType, Integer> entry : cache.getContentMap().entrySet()) {
if (first) {
first = false;
} else {
component.append(
Component.text()
.content(" | ")
.color(ThemeType.PASSIVE.getComponentColor()));
}
component.append(
Component.text()
.content(String.valueOf(entry.getValue()))
.color(ThemeType.getByType(entry.getKey()).getComponentColor())
);
}
player.sendActionBar(component.build());
}

private void expCollector(Player player, SlimefunItem blockItem, Block clickedBlock) {
final ExpCollector collector = (ExpCollector) blockItem;
final int volume = collector.getVolumeMap().get(clickedBlock.getLocation());
final TextComponent component = Component.text()
.append(Component.text("Exp Stored: ")
.color(ThemeType.CLICK_INFO.getComponentColor())
.decoration(TextDecoration.BOLD, true))
.append(Component.text(String.valueOf(volume))
.color(ThemeType.PASSIVE.getComponentColor()))
.build();
player.sendActionBar(component);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.github.sefiraat.crystamaehistoria.CrystamaeHistoria;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.chroniclerpanel.ChroniclerPanel;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.CursedEarth;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.ExpCollector;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.MobFan;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.MobLamp;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.MobMat;
Expand Down Expand Up @@ -48,6 +49,10 @@ public class Gadgets {
private static MobMat doomedPlate;
@Getter
private static MobMat evisceratingPlate;
@Getter
private static ExpCollector basicExpCollector;
@Getter
private static ExpCollector infusedExpCollector;

public static void setup() {

Expand Down Expand Up @@ -285,7 +290,7 @@ public static void setup() {
true
);

// Doomed Plate
// Eviscerating Plate
RecipeItem evisceratingPlateRecipe = new RecipeItem(
doomedPlate.getItem(),
StoryType.ALCHEMICAL, 480,
Expand All @@ -312,6 +317,59 @@ public static void setup() {
true
);

// Basic Exp Collector Plate
RecipeItem basicExpCollectorRecipe = new RecipeItem(
SlimefunItems.EXP_COLLECTOR,
StoryType.MECHANICAL, 150,
StoryType.HUMAN, 200,
StoryType.ANIMAL, 250
);
basicExpCollector = new ExpCollector(
ItemGroups.GADGETS,
ThemeType.themedSlimefunItemStack(
"CRY_EXP_COLLECTOR_1",
new ItemStack(Material.LIGHTNING_ROD),
ThemeType.MECHANISM,
"Basic Exp Collector",
"Infusing the Exp Collector with",
"magic now allows it to work",
"without electricity and flasks.",
"",
ThemeType.CLICK_INFO.getColor() + "Range: " + ThemeType.PASSIVE.getColor() + "4",
ThemeType.CLICK_INFO.getColor() + "Capacity: " + ThemeType.PASSIVE.getColor() + "2500"
),
DummyLiquefactionBasinCrafting.TYPE,
basicExpCollectorRecipe.getDisplayRecipe(),
2500,
4
);

// Infused Exp Collector Plate
RecipeItem infusedExpCollectorRecipe = new RecipeItem(
basicExpCollector.getItem(),
StoryType.MECHANICAL, 740,
StoryType.HUMAN, 560,
StoryType.ANIMAL, 885
);
infusedExpCollector = new ExpCollector(
ItemGroups.GADGETS,
ThemeType.themedSlimefunItemStack(
"CRY_EXP_COLLECTOR_2",
new ItemStack(Material.LIGHTNING_ROD),
ThemeType.MECHANISM,
"Infused Exp Collector",
"Further infusion has made the",
"collector even more powerful.",
"",
ThemeType.CLICK_INFO.getColor() + "Range: " + ThemeType.PASSIVE.getColor() + "8",
ThemeType.CLICK_INFO.getColor() + "Capacity: " + ThemeType.PASSIVE.getColor() + "10000"
),
DummyLiquefactionBasinCrafting.TYPE,
infusedExpCollectorRecipe.getDisplayRecipe(),
10000,
8
);

// Slimefun Registry
abstractionLamp.register(plugin);
dispersionLamp.register(plugin);
Expand All @@ -322,6 +380,8 @@ public static void setup() {
searingPlate.register(plugin);
doomedPlate.register(plugin);
evisceratingPlate.register(plugin);
basicExpCollector.register(plugin);
infusedExpCollector.register(plugin);

// Liquefaction Recipes
LiquefactionBasinCache.addCraftingRecipe(abstractionLamp, abstractionLampRecipe);
Expand All @@ -335,5 +395,8 @@ public static void setup() {
LiquefactionBasinCache.addCraftingRecipe(searingPlate, searingPlateRecipe);
LiquefactionBasinCache.addCraftingRecipe(doomedPlate, doomedPlateRecipe);
LiquefactionBasinCache.addCraftingRecipe(evisceratingPlate, evisceratingPlateRecipe);

LiquefactionBasinCache.addCraftingRecipe(basicExpCollector, basicExpCollectorRecipe);
LiquefactionBasinCache.addCraftingRecipe(infusedExpCollector, infusedExpCollectorRecipe);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public static void setup() {
Skulls.getByType(type).getPlayerHead(),
ThemeType.CRYSTAL,
theme.getColor() + TextUtils.toTitleCase(rarity.toString() + " " + type.toString()) + " Crystal",
"Magical Crystamae in it's physical form"
"Magical Crystamae in it's physical form",
"Higher tier blocks are more likely to",
"provide rarer Crystal types.",
"",
"Provides " + Crystal.getRarityValueMap().get(rarity) + " Crysta."
),
DummyRealisationAltar.TYPE,
new ItemStack[]{null, null, null, null, new ItemStack(Material.AMETHYST_CLUSTER), null, null, null, null},
Expand All @@ -106,8 +110,6 @@ public static void setup() {
}
}



// Amalgamate Dust Common
amalgamateDustCommon = new SlimefunItem(
ItemGroups.MATERIALS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ null, new ItemStack(Material.BOOK), null,
SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), SlimefunItems.REINFORCED_ALLOY_INGOT,
SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.COMMON_TALISMAN, SlimefunItems.REINFORCED_ALLOY_INGOT
},
500
500,
Color.fromRGB(150, 150, 150)
);

// Liquefaction T2
Expand All @@ -300,7 +301,8 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun
amalgamateDustRare, liquefactionBasin1.getItem(), amalgamateDustRare,
amalgamateDustRare, SlimefunItems.ENCHANTMENT_RUNE, amalgamateDustRare
},
1000
1000,
Color.fromRGB(195, 195, 150)
);

// Liquefaction T3
Expand All @@ -325,7 +327,8 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun
),
DummyLiquefactionBasinCrafting.TYPE,
liquefactionT3Recipe.getDisplayRecipe(),
2500
2500,
Color.fromRGB(215, 200, 110)
);

// Liquefaction T4
Expand All @@ -350,7 +353,8 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun
),
DummyLiquefactionBasinCrafting.TYPE,
liquefactionT4Recipe.getDisplayRecipe(),
5000
5000,
Color.fromRGB(240, 220, 26)
);

// Stave Configurator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ null, new ItemStack(Material.STICK), null,
"This magical lens has glass that can",
"the lights of Crysta into it's",
"individual elements.",
ThemeType.CLICK_INFO.getColor() + "Right Click: " + ThemeType.PASSIVE.getColor() + "Shows the contents",
ThemeType.PASSIVE.getColor() + "of a Liquefaction Basin."
"",
"Right click on a Crystamae Block for",
"details if avilable.",
ThemeType.CLICK_INFO.getColor() + "Works with;",
ThemeType.PASSIVE.getColor() + "Liquefaction Basin",
ThemeType.PASSIVE.getColor() + "Exp Collector"
),
RecipeType.MAGIC_WORKBENCH,
new ItemStack[]{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.github.sefiraat.crystamaehistoria.CrystamaeHistoria;
import io.github.sefiraat.crystamaehistoria.slimefun.ItemGroups;
import io.github.sefiraat.crystamaehistoria.slimefun.Materials;
import io.github.sefiraat.crystamaehistoria.stories.StoriedBlockDefinition;
import io.github.sefiraat.crystamaehistoria.stories.BlockDefinition;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryType;
import io.github.sefiraat.crystamaehistoria.utils.PlayerStatUtils;
import io.github.sefiraat.crystamaehistoria.utils.theme.GuiElements;
Expand Down Expand Up @@ -86,15 +86,15 @@ public void open(Player p, PlayerProfile profile, SlimefunGuideMode mode) {
}

private void setupPage(@Nonnull Player p, @Nonnull PlayerProfile profile, @Nonnull SlimefunGuideMode mode, @Nonnull ChestMenu menu, int page) {
final List<StoriedBlockDefinition> blockDefinitions = new ArrayList<>(CrystamaeHistoria.getStoriesManager().getStoriedBlockDefinitionMap().values());
final int numberOfBlocks = CrystamaeHistoria.getStoriesManager().getStoriedBlockDefinitionMap().size();
final List<BlockDefinition> blockDefinitions = new ArrayList<>(CrystamaeHistoria.getStoriesManager().getBlockDefinitionMap().values());
final int numberOfBlocks = CrystamaeHistoria.getStoriesManager().getBlockDefinitionMap().size();
final int totalPages = (int) Math.ceil(numberOfBlocks / (double) PAGE_SIZE);
final int start = (page - 1) * PAGE_SIZE;
final int end = Math.min(start + PAGE_SIZE, blockDefinitions.size());

blockDefinitions.sort(Comparator.comparing(definition -> definition.getMaterial().name()));

final List<StoriedBlockDefinition> blockDefinitionSubList = blockDefinitions.subList(start, end);
final List<BlockDefinition> blockDefinitionSubList = blockDefinitions.subList(start, end);

reapplyFooter(p, profile, mode, menu, page, totalPages);

Expand All @@ -109,7 +109,7 @@ private void setupPage(@Nonnull Player p, @Nonnull PlayerProfile profile, @Nonnu
final int slot = i + 9;

if (i + 1 <= blockDefinitionSubList.size()) {
final StoriedBlockDefinition definition = blockDefinitionSubList.get(i);
final BlockDefinition definition = blockDefinitionSubList.get(i);
final boolean researched = PlayerStatUtils.hasUnlockedUniqueStory(p, definition);

if (mode == SlimefunGuideMode.CHEAT_MODE || researched) {
Expand All @@ -129,7 +129,7 @@ private void setupPage(@Nonnull Player p, @Nonnull PlayerProfile profile, @Nonnu
}
}

private void displayDefinition(@Nonnull Player p, @Nonnull PlayerProfile profile, @Nonnull SlimefunGuideMode mode, @Nonnull ChestMenu menu, int returnPage, @Nonnull StoriedBlockDefinition definition) {
private void displayDefinition(@Nonnull Player p, @Nonnull PlayerProfile profile, @Nonnull SlimefunGuideMode mode, @Nonnull ChestMenu menu, int returnPage, @Nonnull BlockDefinition definition) {
// Back Button
menu.replaceExistingItem(GUIDE_BACK, ChestMenuUtils.getBackButton(p, Slimefun.getLocalization().getMessage("guide.back.guide")));
menu.addMenuClickHandler(GUIDE_BACK, (player1, slot, itemStack, clickAction) -> {
Expand Down Expand Up @@ -200,7 +200,7 @@ private void reapplyFooter(@Nonnull Player p, @Nonnull PlayerProfile profile, Sl
});
}

private ItemStack getPoolsItemStack(@Nonnull StoriedBlockDefinition definition) {
private ItemStack getPoolsItemStack(@Nonnull BlockDefinition definition) {
final List<StoryType> storyTypes = definition.getPools();
final List<String> lore = Arrays.stream(new String[]{
"When chronicling this item, you",
Expand All @@ -219,15 +219,15 @@ private ItemStack getPoolsItemStack(@Nonnull StoriedBlockDefinition definition)
);
}

private ItemStack getUniqueStoryItemStack(@Nonnull StoriedBlockDefinition definition) {
private ItemStack getUniqueStoryItemStack(@Nonnull BlockDefinition definition) {
return new CustomItemStack(
definition.getMaterial(),
ThemeType.MAIN.getColor() + definition.getUnique().getId(),
definition.getUnique().getStoryLore()
);
}

private ItemStack getTierItemStack(@Nonnull StoriedBlockDefinition definition) {
private ItemStack getTierItemStack(@Nonnull BlockDefinition definition) {
switch (definition.getTier().tier) {
case 1:
return GuiElements.TIER_INDICATOR_1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@
import org.bukkit.inventory.ItemStack;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.EnumMap;
import java.util.Map;

public class Crystal extends UnplaceableBlock {

protected static final Map<StoryRarity, Integer> RARITY_VALUE_MAP = new EnumMap<>(StoryRarity.class);
static {
RARITY_VALUE_MAP.put(StoryRarity.COMMON, 1);
RARITY_VALUE_MAP.put(StoryRarity.UNCOMMON, 3);
RARITY_VALUE_MAP.put(StoryRarity.RARE, 10);
RARITY_VALUE_MAP.put(StoryRarity.EPIC, 25);
RARITY_VALUE_MAP.put(StoryRarity.MYTHICAL, 50);
RARITY_VALUE_MAP.put(StoryRarity.UNIQUE, 2);
}

@Getter
private final StoryType type;
@Getter
Expand All @@ -25,4 +37,8 @@ public Crystal(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeTyp
this.rarity = rarity;
}

public static Map<StoryRarity, Integer> getRarityValueMap() {
return RARITY_VALUE_MAP;
}

}
Loading

0 comments on commit 7e41116

Please sign in to comment.