Skip to content

Commit

Permalink
Merge pull request #183 from Sefiraat/feature/10
Browse files Browse the repository at this point in the history
10
  • Loading branch information
Sefiraat authored Mar 9, 2023
2 parents da54bb2 + 0d532d3 commit 6b59860
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public class CrystaStacks {
public static final SlimefunItemStack BIRTHDAY_TROPHY_BWHITE;
public static final SlimefunItemStack BIRTHDAY_TROPHY_DECOY;
public static final SlimefunItemStack BIRTHDAY_TROPHY_ODDISH;
public static final SlimefunItemStack ANNIVERSARY_TROPHY;

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

ANNIVERSARY_TROPHY = ThemeType.themedSlimefunItemStack(
"CRY_ANNIVERSARY_TROPHY",
new ItemStack(Material.COOKIE),
ThemeType.CRAFTING,
"Slimefun's 10th Anniversary",
"10 Years of (Slime)fun",
"",
ThemeType.CLICK_INFO.getColor() + "Requires: Slimefun's Anniversary"
);

// Recipe Types

RECIPE_TYPE_LIQUEFACTION_CRAFTING = ThemeType.themedItemStack(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class Uniques {
private static Trophy birthdayTrophyDecoy;
@Getter
private static Trophy birthdayTrophyOddish;
@Getter
private static Trophy tenthAnniversaryTrophy;

public static void setup() {

Expand Down Expand Up @@ -282,11 +284,56 @@ public static void setup() {
}
);

// Tenth Anniversary
RecipeItem anniversaryTrophy = new RecipeItem(
new ItemStack(Material.COOKIE),
StoryType.HUMAN, 500,
StoryType.ELEMENTAL, 500,
StoryType.VOID, 500,
Uniques::isTenthAnniversary
);
tenthAnniversaryTrophy = new Trophy(
ItemGroups.UNIQUES,
CrystaStacks.ANNIVERSARY_TROPHY,
CrystaRecipeTypes.LIQUEFACTION_CRAFTING,
anniversaryTrophy.getDisplayRecipe(),
location -> {
final int rand = ThreadLocalRandom.current().nextInt(9);

if (rand != 0) {
return;
}

for (int i = 0; i < 4; i++) {
final Location spawnLocation = location.add(0, 0.3, 0);
final Color color = Color.fromRGB(55, 180, 30);
spawnBirthdayFirework(spawnLocation, color);
ParticleUtils.displayParticleEffect(
spawnLocation,
1,
3,
new Particle.DustOptions(color, 2)
);
}

final Location spawnLocation = location.add(0, 0.2, 0);
final Color color = Color.fromRGB(255, 255, 255);
spawnBirthdayFirework(spawnLocation, color);
ParticleUtils.displayParticleEffect(
spawnLocation,
1,
3,
new Particle.DustOptions(color, 2)
);
}
);

spellTrophy.register(plugin);
storyTrophy.register(plugin);
gildingTrophy.register(plugin);
christmasTrophy.register(plugin);
valentinesTrophy.register(plugin);
tenthAnniversaryTrophy.register(plugin);

birthdayTrophyCheesy.register(plugin);
birthdayTrophyBWhite.register(plugin);
Expand Down Expand Up @@ -328,7 +375,7 @@ private static boolean isChristmas(@Nonnull Player player) {
private static boolean isBirthdayCheesy(@Nonnull Player player) {
final LocalDate now = LocalDate.now();
final int year = now.getYear();
final LocalDate start = LocalDate.of(year, 3, 29);
final LocalDate start = LocalDate.of(year, 3, 28);
final LocalDate end = LocalDate.of(year, 3, 30);

return now.isAfter(start) && now.isBefore(end);
Expand All @@ -337,26 +384,26 @@ private static boolean isBirthdayCheesy(@Nonnull Player player) {
private static boolean isBirthdayBWhite(@Nonnull Player player) {
final LocalDate now = LocalDate.now();
final int year = now.getYear();
final LocalDate start = LocalDate.of(year, 9, 10);
final LocalDate end = LocalDate.of(year, 9, 10);
final LocalDate start = LocalDate.of(year, 9, 9);
final LocalDate end = LocalDate.of(year, 9, 11);

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

private static boolean isBirthdayDecoy(@Nonnull Player player) {
final LocalDate now = LocalDate.now();
final int year = now.getYear();
final LocalDate start = LocalDate.of(year, 12, 11);
final LocalDate end = LocalDate.of(year, 12, 11);
final LocalDate start = LocalDate.of(year, 12, 10);
final LocalDate end = LocalDate.of(year, 12, 12);

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

private static boolean isBirthdayOddish(@Nonnull Player player) {
final LocalDate now = LocalDate.now();
final int year = now.getYear();
final LocalDate start = LocalDate.of(year, 2, 12);
final LocalDate end = LocalDate.of(year, 2, 12);
final LocalDate start = LocalDate.of(year, 2, 11);
final LocalDate end = LocalDate.of(year, 2, 13);

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

private static boolean isTenthAnniversary(@Nonnull Player player) {
final LocalDate now = LocalDate.now();
final int year = 2023;
final LocalDate start = LocalDate.of(year, 3, 8);
final LocalDate end = LocalDate.of(year, 3, 22);

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

private static void spawnBirthdayFirework(@Nonnull Location location, @Nonnull Color color) {
final Firework firework = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
final FireworkMeta fireworkMeta = firework.getFireworkMeta();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -41,6 +43,11 @@ public void onRightClick(PlayerRightClickEvent e) {
e.cancel();

final Block blockClicked = optionalBlock.get();

if (!Slimefun.getProtectionManager().hasPermission(player, blockClicked, Interaction.BREAK_BLOCK)) {
return;
}

final UUID currentItemUuid = itemMap.get(blockClicked.getLocation());

if (currentItemUuid != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -63,6 +65,11 @@ public void onRightClick(PlayerRightClickEvent e) {
e.cancel();

final Block blockClicked = optionalBlock.get();

if (!Slimefun.getProtectionManager().hasPermission(player, blockClicked, Interaction.BREAK_BLOCK)) {
return;
}

final UUID currentItemUuid = itemMap.get(blockClicked.getLocation());

// Stand already has an item, we try to remove this then return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
import org.bukkit.Location;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
Expand All @@ -18,14 +19,20 @@ public class Trophy extends SlimefunItem {
private final Consumer<Location> displayConsumer;

@ParametersAreNonnullByDefault
public Trophy(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, Consumer<Location> displayConsumer) {
public Trophy(ItemGroup itemGroup,
SlimefunItemStack item,
RecipeType recipeType,
ItemStack[] recipe,
Consumer<Location> displayConsumer
) {
super(itemGroup, item, recipeType, recipe);
this.displayConsumer = displayConsumer;
}

@Override
public void preRegister() {
addItemHandler(onBlockPlace());
addItemHandler(onConsume());
}

private BlockPlaceHandler onBlockPlace() {
Expand All @@ -37,6 +44,10 @@ public void onPlayerPlace(@NotNull BlockPlaceEvent e) {
};
}

private ItemConsumptionHandler onConsume() {
return (e, p, item) -> e.setCancelled(true);
}

public Consumer<Location> getDisplayConsumer() {
return displayConsumer;
}
Expand Down

0 comments on commit 6b59860

Please sign in to comment.