Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCCore first pull request #176

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.hackclub.hccore.advancements;

import com.fren_gor.ultimateAdvancementAPI.advancement.Advancement;
import com.fren_gor.ultimateAdvancementAPI.advancement.BaseAdvancement;
import com.fren_gor.ultimateAdvancementAPI.advancement.display.AdvancementDisplay;
import com.fren_gor.ultimateAdvancementAPI.advancement.display.AdvancementDisplayBuilder;
import com.fren_gor.ultimateAdvancementAPI.util.AdvancementKey;
import com.fren_gor.ultimateAdvancementAPI.util.CoordAdapter;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.event.entity.EntityDeathEvent;

public class MasterMobSlayerAdv extends BaseAdvancement {

static final AdvancementDisplayBuilder<AdvancementDisplay.Builder, AdvancementDisplay> displayBuilder = new AdvancementDisplay.Builder(
Material.NETHERITE_AXE, "Master Mob Slayer")
.challengeFrame()
.announceChat()
.showToast()
.description("Kill EVERY hostile Mob 10 times");
static final int maxProgression = 640; // 10 times for each of the 64 hostile mobs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this mean that I could just kill 640 endermen in a farm and get the advancement?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont know
i thought it meant that you need to kill 10 of each hostile mob to get the advancement

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I haven't tested it, but from what I see, it's not tracking how many of each mob you've killed, just how many mobs in total

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@polypixeldev i dont know how to make it count 10 of each mob death tho...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is a bit of a tough one to do. The only way I can think of would be to add a map to the PlayerData class which stores how many of each mob they've killed, and update it accordingly in the EntityDeathEvent handler.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't really need a map as player stats are already stored


public MasterMobSlayerAdv(Advancement root, AdvancementKey key,
CoordAdapter adapter) {
super(key.getKey(), displayBuilder.coords(adapter, key).build(), root, maxProgression);

registerEvent(EntityDeathEvent.class, e -> {
if (isHostile(e.getEntityType())) {
if (e.getEntity().getKiller() != null) {
incrementProgression(e.getEntity().getKiller());
}
}
});
}

private boolean isHostile(EntityType entityType) {
switch (entityType) {
case BLAZE:
case CREEPER:
case DROWNED:
case ELDER_GUARDIAN:
case ENDERMAN:
case ENDERMITE:
case EVOKER:
case GHAST:
case GUARDIAN:
case HOGLIN:
case HUSK:
case MAGMA_CUBE:
case PHANTOM:
case PIGLIN:
case PIGLIN_BRUTE:
case PILLAGER:
case RAVAGER:
case SHULKER:
case SILVERFISH:
case SKELETON:
case SLIME:
case SPIDER:
case STRAY:
case VEX:
case VINDICATOR:
case WITCH:
case WITHER_SKELETON:
case ZOGLIN:
case ZOMBIE:
case ZOMBIE_VILLAGER:
case ZOMBIFIED_PIGLIN:
return true;
default:
return false;
}
}
}
32 changes: 32 additions & 0 deletions src/main/java/com/hackclub/hccore/advancements/NoSleepAdv.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.hackclub.hccore.advancements;

import com.fren_gor.ultimateAdvancementAPI.advancement.Advancement;
import com.fren_gor.ultimateAdvancementAPI.advancement.BaseAdvancement;
import com.fren_gor.ultimateAdvancementAPI.advancement.display.AdvancementDisplay;
import com.fren_gor.ultimateAdvancementAPI.advancement.display.AdvancementDisplayBuilder;
import com.fren_gor.ultimateAdvancementAPI.util.AdvancementKey;
import com.fren_gor.ultimateAdvancementAPI.util.CoordAdapter;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.event.player.PlayerBedEnterEvent;

public class NoSleepAdv extends BaseAdvancement {
static final AdvancementDisplayBuilder<AdvancementDisplay.Builder, AdvancementDisplay> displayBuilder =
new AdvancementDisplay.Builder(Material.RED_BED, "Please Sleep")
.challengeFrame()
.announceChat()
.showToast()
.description("Go to bed after staying up for a full week");
static final int maxProgression = 1;

public NoSleepAdv(Advancement root, AdvancementKey key,
CoordAdapter adapter) {
super(key.getKey(), displayBuilder.coords(adapter, key).build(), root, maxProgression);

registerEvent(PlayerBedEnterEvent.class, e -> {
456dev marked this conversation as resolved.
Show resolved Hide resolved
if (e.getPlayer().getStatistic(Statistic.TIME_SINCE_REST) >= 20 * 60 * 60 * 24 * 7) {
grant(e.getPlayer());
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.hackclub.hccore.advancements;

import com.fren_gor.ultimateAdvancementAPI.advancement.Advancement;
import com.fren_gor.ultimateAdvancementAPI.advancement.BaseAdvancement;
import com.fren_gor.ultimateAdvancementAPI.advancement.display.AdvancementDisplay;
import com.fren_gor.ultimateAdvancementAPI.advancement.display.AdvancementDisplayBuilder;
import com.fren_gor.ultimateAdvancementAPI.util.AdvancementKey;
import com.fren_gor.ultimateAdvancementAPI.util.CoordAdapter;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.event.block.BlockBreakEvent;

public class ObsidianMinerAdv extends BaseAdvancement {
static final AdvancementDisplayBuilder<AdvancementDisplay.Builder, AdvancementDisplay> displayBuilder =
new AdvancementDisplay.Builder(Material.OBSIDIAN, "Do your fingers hurt?")
.challengeFrame()
.announceChat()
.showToast()
.description("Mine 10 pieces of Obsidian by hand");
static final int maxProgression = 10;

public ObsidianMinerAdv(Advancement root, AdvancementKey key,
CoordAdapter adapter) {
super(key.getKey(), displayBuilder.coords(adapter, key).build(), root, maxProgression);

registerEvent(BlockBreakEvent.class, e -> {
if (e.getBlock().getType() == Material.OBSIDIAN && e.getPlayer().getInventory().getItemInMainHand().getType() == Material.AIR) {
incrementProgression(e.getPlayer());
}
});
}
}
Loading