Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ public void startNext() {
private void launch(ChatAnimation animation) {
animation.setFinished(false);
currentAnimation = animation;
Bukkit.broadcast(currentAnimation.getAnnounceStart());
if (!Bukkit.getOnlinePlayers().isEmpty())
Bukkit.broadcast(currentAnimation.getAnnounceStart());

long timeBeforeEndTicks = animation.getTimeBeforeEnd() * 20L;
endAnimationTask = Bukkit.getScheduler().runTaskLater(OMCPlugin.getInstance(), () -> {
Expand All @@ -189,16 +190,18 @@ public static void onAnimationCompleted(ChatAnimation animation, Player winner,
endAnimationTask = null;
}

if (winner != null) {
Bukkit.broadcast(TranslationManager.translation("feature.chatanimations.winner",
winner.name().color(NamedTextColor.GOLD),
animation.getName(),
animation.getDescriptionResult(),
loot.buildComponent()
));
} else {
Bukkit.broadcast(TranslationManager.translation("feature.chatanimations.no_winner",
animation.getName(), animation.getDescriptionResult()));
if (!Bukkit.getOnlinePlayers().isEmpty()) {
if (winner != null) {
Bukkit.broadcast(TranslationManager.translation("feature.chatanimations.winner",
winner.name().color(NamedTextColor.GOLD),
animation.getName(),
animation.getDescriptionResult(),
loot.buildComponent()
));
} else {
Bukkit.broadcast(TranslationManager.translation("feature.chatanimations.no_winner",
animation.getName(), animation.getDescriptionResult()));
}
}

lastAnimation = currentAnimation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,16 @@ public void onMetalDetectorLoot(MetalDetectorLootEvent event) {
for (CustomLoot loot : event.getLoot()) {
if (!(loot instanceof ItemLoot itemLoot)) continue;

for (ItemStack item : itemLoot.getItems()) {
DreamItem dreamItem = DreamItemRegistry.getByItemStack(item);
DreamItem dreamItem = DreamItemRegistry.getByItemStack(itemLoot.getItemLootWithAmount());

if (dreamItem == null) continue;
if (!dreamItem.getId().equals(DreamItemRegistry.MUD_ORB.getId())) continue;
if (dreamItem == null) continue;
if (!dreamItem.getId().equals(DreamItemRegistry.MUD_ORB.getId())) continue;

setProgressionOrb(player, MUD_BEACH_ORB, DreamBiome.GLACITE_GROTTO);
setProgressionOrb(player, MUD_BEACH_ORB, DreamBiome.GLACITE_GROTTO);

// * SFX
player.getWorld().playSound(player.getLocation(), "minecraft:entity.wither.spawn", 1f, 2f);
ParticleUtils.spawnDispersingParticles(player.getLocation(), Particle.ASH, 15, 15, 0.5, null);
break;
}
// * SFX
player.getWorld().playSound(player.getLocation(), "minecraft:entity.wither.spawn", 1f, 2f);
ParticleUtils.spawnDispersingParticles(player.getLocation(), Particle.ASH, 15, 15, 0.5, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.bukkit.inventory.ItemStack;

import java.util.List;
import java.util.Set;

public class CloudVault implements Listener {
private final CustomLootTable CLOUD_VAULT_LOOT_TABLE = DreamLootTableRegistry.CLOUD_VAULT;
Expand Down Expand Up @@ -51,8 +50,7 @@ public void onLootGenerate(BlockDispenseLootEvent event) {
.map(item -> (ItemLoot) item).toList();

List<ItemStack> itemStacks = itemLoots.stream()
.map(ItemLoot::getItems)
.flatMap(Set::stream)
.map(ItemLoot::getItemLootWithAmount)
.toList();

event.setDispensedLoot(itemStacks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;

public class CrystallizedPickaxeQuest extends MilestoneQuest implements Listener {
Expand Down Expand Up @@ -76,13 +75,11 @@ public void onPickUp(MetalDetectorLootEvent e) {
for (CustomLoot loot : e.getLoot()) {
if (!(loot instanceof ItemLoot itemLoot)) continue;

for (ItemStack item : itemLoot.getItems()) {
DreamItem dreamItem = DreamItemRegistry.getByItemStack(item);
if (dreamItem == null) return;
if (dreamItem instanceof CrystalizedPickaxe) {
if (MilestonesManager.getPlayerStep(getType(), player) != getStep().ordinal()) continue;
this.incrementProgressInDream(player.getUniqueId());
}
DreamItem dreamItem = DreamItemRegistry.getByItemStack(itemLoot.getItemLootWithAmount());
if (dreamItem == null) return;
if (dreamItem instanceof CrystalizedPickaxe) {
if (MilestonesManager.getPlayerStep(getType(), player) != getStep().ordinal()) continue;
this.incrementProgressInDream(player.getUniqueId());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;

public class MudOrbQuest extends MilestoneQuest implements Listener {

Expand Down Expand Up @@ -44,13 +43,11 @@ public void onGetOrb(MetalDetectorLootEvent e) {
for (CustomLoot loot : e.getLoot()) {
if (!(loot instanceof ItemLoot itemLoot)) continue;

for (ItemStack item : itemLoot.getItems()) {
DreamItem dreamItem = DreamItemRegistry.getByItemStack(item);
if (dreamItem == null) return;
if (dreamItem instanceof MudOrb) {
if (MilestonesManager.getPlayerStep(getType(), player) != getStep().ordinal()) return;
this.incrementProgressInDream(player.getUniqueId());
}
DreamItem dreamItem = DreamItemRegistry.getByItemStack(itemLoot.getItemLootWithAmount());
if (dreamItem == null) return;
if (dreamItem instanceof MudOrb) {
if (MilestonesManager.getPlayerStep(getType(), player) != getStep().ordinal()) return;
this.incrementProgressInDream(player.getUniqueId());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void registerSoulLink(Vex vex, ArmorStand stand) {
if (Math.random() >= loot.getChance()) return;

int amount = loot.getMinAmount() + (int) (Math.random() * (loot.getMaxAmount() - loot.getMinAmount() + 1));
ItemStack drop = loot.getFirstLoot().asQuantity(amount);
ItemStack drop = loot.getItemLootWithAmount().asQuantity(amount);
dead.getWorld().dropItemNaturally(dead.getLocation(), drop);
}
} else if (dead.equals(stand) && vex.isValid()) {
Expand All @@ -134,7 +134,7 @@ private void registerSoulLink(Vex vex, ArmorStand stand) {
if (Math.random() >= loot.getChance()) return;

int amount = loot.getMinAmount() + (int) (Math.random() * (loot.getMaxAmount() - loot.getMinAmount() + 1));
ItemStack drop = loot.getFirstLoot().asQuantity(amount);
ItemStack drop = loot.getItemLootWithAmount().asQuantity(amount);
dead.getWorld().dropItemNaturally(dead.getLocation(), drop);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ public void onGetRewardLootBox(LootboxRewardEvent event) {

if (!(event.getLoot() instanceof ItemLoot itemLoot)) return;

boolean hasLootPelucheSeinyy = itemLoot.getItems().stream()
.filter(loot -> OMCRegistry.CUSTOM_ITEMS.get(loot).isPresent())
.anyMatch(loot -> OMCRegistry.CUSTOM_ITEMS.getOrThrow(loot).getId().equals(pelushKey));
boolean hasLootPelucheSeinyy = false;
if (OMCRegistry.CUSTOM_ITEMS.get(itemLoot.getItemLootWithAmount()).isPresent()) {
hasLootPelucheSeinyy = OMCRegistry.CUSTOM_ITEMS.getOrThrow(itemLoot.getItemLootWithAmount())
.getId().equals(pelushKey);
}

Player player = event.getPlayer();
PlayerStats ps = TicketManager.getPlayerStats(player.getUniqueId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public String getTexture() {

ItemStack itemDisplay = loot.getRepresentativeItem();

if (loot instanceof ItemLoot itemLoot && itemLoot.getDisplayedItem() != null) {
itemDisplay = itemLoot.getDisplayedItem();
if (loot instanceof ItemLoot itemLoot && itemLoot.getItemLootWithAmount() != null) {
itemDisplay = itemLoot.getItemLootWithAmount();
}

if (itemDisplay == null) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public double getChanceOf(ItemStack item) {
return this.getLoots().stream()
.filter(loot -> loot instanceof ItemLoot)
.map(loot -> (ItemLoot) loot)
.filter(loot -> loot.getItems().stream()
.anyMatch(lootItem -> ItemUtils.isSimilar(lootItem, item)))
.filter(loot -> ItemUtils.isSimilar(loot.getItemLootWithAmount(), item))
.mapToDouble(CustomLoot::getChance)
.sum();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Component buildComponent() {
for (CustomLoot loot : loots) {
int amount = -1;
if (loot instanceof ItemLoot itemLoot) {
amount = itemLoot.getRepresentativeItem().getAmount();
amount = itemLoot.getItemLootWithAmount().getAmount();
}
Component lootComponent = loot.buildLootComponent(amount);
if (lootComponent == null) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import fr.openmc.core.utils.text.messages.TranslationManager;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

import java.util.LinkedHashSet;
import java.util.List;
Expand All @@ -29,7 +28,6 @@ public String getNamespace() {
public Set<CustomLoot> getLoots() {
return new LinkedHashSet<>(List.of(
new ItemLoot(
Set.of(OMCRegistry.CUSTOM_ITEMS.PELUCHE_SEINYY.getBest()),
new ItemBuilder(
OMCRegistry.CUSTOM_ITEMS.PELUCHE_SEINYY,
meta -> {
Expand All @@ -42,7 +40,6 @@ public Set<CustomLoot> getLoots() {
1
),
new ItemLoot(
Set.of(ItemStack.of(Material.DIAMOND)),
new ItemBuilder(
Material.DIAMOND,
meta -> {
Expand All @@ -55,7 +52,6 @@ public Set<CustomLoot> getLoots() {
3
),
new ItemLoot(
Set.of(ItemStack.of(Material.IRON_INGOT)),
new ItemBuilder(
Material.IRON_INGOT,
meta -> {
Expand All @@ -68,7 +64,6 @@ public Set<CustomLoot> getLoots() {
10
),
new ItemLoot(
Set.of(ItemStack.of(Material.NETHERITE_INGOT)),
new ItemBuilder(
Material.NETHERITE_INGOT,
meta -> {
Expand All @@ -81,7 +76,6 @@ public Set<CustomLoot> getLoots() {
1
),
new ItemLoot(
Set.of(ItemStack.of(Material.OAK_LOG)),
new ItemBuilder(
Material.OAK_LOG,
meta -> {
Expand All @@ -94,7 +88,6 @@ public Set<CustomLoot> getLoots() {
32
),
new ItemLoot(
Set.of(ItemStack.of(Material.COOKED_BEEF)),
new ItemBuilder(
Material.COOKED_BEEF,
meta -> {
Expand All @@ -107,7 +100,6 @@ public Set<CustomLoot> getLoots() {
16
),
new ItemLoot(
Set.of(ItemStack.of(Material.COAL)),
new ItemBuilder(
Material.COAL,
meta -> {
Expand Down
Loading
Loading