Skip to content

Commit d67a92c

Browse files
committed
10
1 parent 340f1a9 commit d67a92c

File tree

3 files changed

+86
-8
lines changed

3 files changed

+86
-8
lines changed

src/main/java/io/github/sefiraat/crystamaehistoria/slimefun/CrystaStacks.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ public class CrystaStacks {
236236
public static final SlimefunItemStack BIRTHDAY_TROPHY_BWHITE;
237237
public static final SlimefunItemStack BIRTHDAY_TROPHY_DECOY;
238238
public static final SlimefunItemStack BIRTHDAY_TROPHY_ODDISH;
239+
public static final SlimefunItemStack ANNIVERSARY_TROPHY;
239240

240241
// Recipe Types
241242
public static final ItemStack RECIPE_TYPE_LIQUEFACTION_CRAFTING;
@@ -2407,6 +2408,16 @@ public class CrystaStacks {
24072408
ThemeType.CLICK_INFO.getColor() + "Requires: Oddish's Birthday!"
24082409
);
24092410

2411+
ANNIVERSARY_TROPHY = ThemeType.themedSlimefunItemStack(
2412+
"CRY_ANNIVERSARY_TROPHY",
2413+
new ItemStack(Material.COOKIE),
2414+
ThemeType.CRAFTING,
2415+
"Slimefun's 10th Anniversary",
2416+
"10 Years of (Slime)fun",
2417+
"",
2418+
ThemeType.CLICK_INFO.getColor() + "Requires: Slimefun's Anniversary"
2419+
);
2420+
24102421
// Recipe Types
24112422

24122423
RECIPE_TYPE_LIQUEFACTION_CRAFTING = ThemeType.themedItemStack(

src/main/java/io/github/sefiraat/crystamaehistoria/slimefun/Uniques.java

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public class Uniques {
4949
private static Trophy birthdayTrophyDecoy;
5050
@Getter
5151
private static Trophy birthdayTrophyOddish;
52+
@Getter
53+
private static Trophy tenthAnniversaryTrophy;
5254

5355
public static void setup() {
5456

@@ -282,11 +284,56 @@ public static void setup() {
282284
}
283285
);
284286

287+
// Tenth Anniversary
288+
RecipeItem anniversaryTrophy = new RecipeItem(
289+
new ItemStack(Material.COOKIE),
290+
StoryType.HUMAN, 500,
291+
StoryType.ELEMENTAL, 500,
292+
StoryType.VOID, 500,
293+
Uniques::isTenthAnniversary
294+
);
295+
tenthAnniversaryTrophy = new Trophy(
296+
ItemGroups.UNIQUES,
297+
CrystaStacks.ANNIVERSARY_TROPHY,
298+
CrystaRecipeTypes.LIQUEFACTION_CRAFTING,
299+
anniversaryTrophy.getDisplayRecipe(),
300+
location -> {
301+
final int rand = ThreadLocalRandom.current().nextInt(9);
302+
303+
if (rand != 0) {
304+
return;
305+
}
306+
307+
for (int i = 0; i < 4; i++) {
308+
final Location spawnLocation = location.add(0, 0.3, 0);
309+
final Color color = Color.fromRGB(55, 180, 30);
310+
spawnBirthdayFirework(spawnLocation, color);
311+
ParticleUtils.displayParticleEffect(
312+
spawnLocation,
313+
1,
314+
3,
315+
new Particle.DustOptions(color, 2)
316+
);
317+
}
318+
319+
final Location spawnLocation = location.add(0, 0.2, 0);
320+
final Color color = Color.fromRGB(255, 255, 255);
321+
spawnBirthdayFirework(spawnLocation, color);
322+
ParticleUtils.displayParticleEffect(
323+
spawnLocation,
324+
1,
325+
3,
326+
new Particle.DustOptions(color, 2)
327+
);
328+
}
329+
);
330+
285331
spellTrophy.register(plugin);
286332
storyTrophy.register(plugin);
287333
gildingTrophy.register(plugin);
288334
christmasTrophy.register(plugin);
289335
valentinesTrophy.register(plugin);
336+
tenthAnniversaryTrophy.register(plugin);
290337

291338
birthdayTrophyCheesy.register(plugin);
292339
birthdayTrophyBWhite.register(plugin);
@@ -328,7 +375,7 @@ private static boolean isChristmas(@Nonnull Player player) {
328375
private static boolean isBirthdayCheesy(@Nonnull Player player) {
329376
final LocalDate now = LocalDate.now();
330377
final int year = now.getYear();
331-
final LocalDate start = LocalDate.of(year, 3, 29);
378+
final LocalDate start = LocalDate.of(year, 3, 28);
332379
final LocalDate end = LocalDate.of(year, 3, 30);
333380

334381
return now.isAfter(start) && now.isBefore(end);
@@ -337,26 +384,26 @@ private static boolean isBirthdayCheesy(@Nonnull Player player) {
337384
private static boolean isBirthdayBWhite(@Nonnull Player player) {
338385
final LocalDate now = LocalDate.now();
339386
final int year = now.getYear();
340-
final LocalDate start = LocalDate.of(year, 9, 10);
341-
final LocalDate end = LocalDate.of(year, 9, 10);
387+
final LocalDate start = LocalDate.of(year, 9, 9);
388+
final LocalDate end = LocalDate.of(year, 9, 11);
342389

343390
return now.isAfter(start) && now.isBefore(end);
344391
}
345392

346393
private static boolean isBirthdayDecoy(@Nonnull Player player) {
347394
final LocalDate now = LocalDate.now();
348395
final int year = now.getYear();
349-
final LocalDate start = LocalDate.of(year, 12, 11);
350-
final LocalDate end = LocalDate.of(year, 12, 11);
396+
final LocalDate start = LocalDate.of(year, 12, 10);
397+
final LocalDate end = LocalDate.of(year, 12, 12);
351398

352399
return now.isAfter(start) && now.isBefore(end);
353400
}
354401

355402
private static boolean isBirthdayOddish(@Nonnull Player player) {
356403
final LocalDate now = LocalDate.now();
357404
final int year = now.getYear();
358-
final LocalDate start = LocalDate.of(year, 2, 12);
359-
final LocalDate end = LocalDate.of(year, 2, 12);
405+
final LocalDate start = LocalDate.of(year, 2, 11);
406+
final LocalDate end = LocalDate.of(year, 2, 13);
360407

361408
return now.isAfter(start) && now.isBefore(end);
362409
}
@@ -370,6 +417,15 @@ private static boolean isValentines(@Nonnull Player player) {
370417
return now.isAfter(start) && now.isBefore(end);
371418
}
372419

420+
private static boolean isTenthAnniversary(@Nonnull Player player) {
421+
final LocalDate now = LocalDate.now();
422+
final int year = 2023;
423+
final LocalDate start = LocalDate.of(year, 3, 8);
424+
final LocalDate end = LocalDate.of(year, 3, 22);
425+
426+
return now.isAfter(start) && now.isBefore(end);
427+
}
428+
373429
private static void spawnBirthdayFirework(@Nonnull Location location, @Nonnull Color color) {
374430
final Firework firework = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
375431
final FireworkMeta fireworkMeta = firework.getFireworkMeta();

src/main/java/io/github/sefiraat/crystamaehistoria/slimefun/items/materials/Trophy.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
66
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
77
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
8+
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
89
import org.bukkit.Location;
910
import org.bukkit.event.block.BlockPlaceEvent;
1011
import org.bukkit.inventory.ItemStack;
@@ -18,14 +19,20 @@ public class Trophy extends SlimefunItem {
1819
private final Consumer<Location> displayConsumer;
1920

2021
@ParametersAreNonnullByDefault
21-
public Trophy(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, Consumer<Location> displayConsumer) {
22+
public Trophy(ItemGroup itemGroup,
23+
SlimefunItemStack item,
24+
RecipeType recipeType,
25+
ItemStack[] recipe,
26+
Consumer<Location> displayConsumer
27+
) {
2228
super(itemGroup, item, recipeType, recipe);
2329
this.displayConsumer = displayConsumer;
2430
}
2531

2632
@Override
2733
public void preRegister() {
2834
addItemHandler(onBlockPlace());
35+
addItemHandler(onConsume());
2936
}
3037

3138
private BlockPlaceHandler onBlockPlace() {
@@ -37,6 +44,10 @@ public void onPlayerPlace(@NotNull BlockPlaceEvent e) {
3744
};
3845
}
3946

47+
private ItemConsumptionHandler onConsume() {
48+
return (e, p, item) -> e.setCancelled(true);
49+
}
50+
4051
public Consumer<Location> getDisplayConsumer() {
4152
return displayConsumer;
4253
}

0 commit comments

Comments
 (0)