Skip to content
Merged
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
2 changes: 2 additions & 0 deletions configuration/skyblock/Minestom.regions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ dark_thicket,DARK_THICKET,-333,148,-24,-415,59,-122,THE_PARK
trial_of_fire,TRIALS_OF_FIRE,-369,120,-100,-357,101,-88,THE_PARK
jungle,JUNGLE_ISLAND,-417,149,-130,-507,68,-18,THE_PARK
savanna,SAVANNA_WOODLAND,-467,155,-20,-383,56,102,THE_PARK
viking,VIKING_LONGHOUSE,-349,50,53,-315,131,94,THE_PARK
melody,MELODY_PLATEAU,-434,100,63,-399,132,101,THE_PARK
sherry,SHERRYS_SHOWROOM,21,98,86,7,76,108,JERRYS_WORKSHOP
jerry,JERRYS_WORKSHOP,139,183,200,-163,30,-167,JERRYS_WORKSHOP
terry,TERRYS_SHACK,-87,94,30,-95,76,21,JERRYS_WORKSHOP
Expand Down
6 changes: 6 additions & 0 deletions configuration/skyblock/items/vanilla/blocks/wood/spruce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ items:
material: SPRUCE_WOOD
rarity: COMMON
components:
- id: CUSTOM_DROP
rules:
- drops:
- item: SPRUCE_LOG
chance: 1
amount: 1
- id: SELLABLE
value: 2.0
- id: PLACEABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ public void cancelDialogue(HypixelPlayer player) {
}

private void handleLineSendingLoop(HypixelPlayer player, HypixelNPC.DialogueSet dialogueSet) {
npc.sendNPCMessage(player, dialogueSet.lines()[0]);
if (dialogueSet.sound() != null) {
npc.sendNPCMessage(player, dialogueSet.lines()[0], dialogueSet.sound());
} else {
npc.sendNPCMessage(player, dialogueSet.lines()[0]);
}

String[] newLines = new String[dialogueSet.lines().length - 1];
System.arraycopy(dialogueSet.lines(), 1, newLines, 0, dialogueSet.lines().length - 1);
Expand All @@ -85,6 +89,7 @@ private void handleLineSendingLoop(HypixelPlayer player, HypixelNPC.DialogueSet
handleLineSendingLoop(player, HypixelNPC.DialogueSet.builder()
.key(dialogueSet.key())
.lines(newLines)
.sound(dialogueSet.sound())
.build());
}
}).delay(TaskSchedule.seconds(2)).schedule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,14 @@ public void unregister() {
}

public void sendNPCMessage(HypixelPlayer player, String message) {
player.sendMessage("§e[NPC] " + getName() + "§f: " + message);
player.playSound(Sound.sound().type(Key.key("entity.villager.celebrate")).volume(1.0f).pitch(0.8f + new Random().nextFloat() * 0.4f).build());
sendNPCMessage(player, message, Sound.sound().type(Key.key("entity.villager.celebrate")).volume(1.0f).pitch(0.8f + new Random().nextFloat() * 0.4f).build());
}

public void sendNPCMessage(HypixelPlayer player, String message, Sound sound) {
player.sendMessage("§e[NPC] " + getName() + "§f: " + message);
player.playSound(sound);
}

protected DialogueController dialogue() {
return dialogueController;
}
Expand Down Expand Up @@ -299,7 +303,7 @@ public Map.Entry<PlayerHolograms.ExternalPlayerHologram, Entity> get(HypixelNPC
}

@Builder
public record DialogueSet(String key, String[] lines) {
public record DialogueSet(String key, String[] lines, Sound sound) {
public static final DialogueSet[] EMPTY = new DialogueSet[0];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ DatapointPetData.class, new DatapointPetData("pet_data")),
QUIVER("quiver", false, false, false,
DatapointQuiver.class, new DatapointQuiver("quiver")),

RACE_BEST_TIME("race_best_time", false, false, false, DatapointMapStringLong.class,
new DatapointMapStringLong("race_best_time")),

ACCESSORY_BAG("accessory_bag", false, false, false,
DatapointAccessoryBag.class, new DatapointAccessoryBag("accessory_bag")),

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package net.swofty.type.skyblockgeneric.event.actions.race;

import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.event.player.PlayerDisconnectEvent;
import net.minestom.server.event.player.PlayerMoveEvent;
import net.minestom.server.event.player.PlayerSpawnEvent;
import net.swofty.type.generic.HypixelConst;
import net.swofty.type.generic.event.EventNodes;
import net.swofty.type.generic.event.HypixelEvent;
import net.swofty.type.generic.event.HypixelEventClass;
import net.swofty.type.skyblockgeneric.race.RaceInstance;
import net.swofty.type.skyblockgeneric.race.RaceManager;
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;

import java.util.HashMap;
import java.util.UUID;

public class RaceEvents implements HypixelEventClass {

private final HashMap<UUID, Long> lastClickedTimes = new HashMap<>();

@HypixelEvent(node = EventNodes.PLAYER, requireDataLoaded = false)
public void onPlayerJoin(PlayerSpawnEvent event) {
SkyBlockPlayer player = (SkyBlockPlayer) event.getPlayer();
if (!(HypixelConst.getTypeLoader() instanceof RaceInstance raceInstance)) {
return;
}
RaceManager race = raceInstance.getRace();
if (race == null) return;

race.updateForPlayer(HypixelConst.getInstanceContainer(), player);
}

@HypixelEvent(node = EventNodes.PLAYER, requireDataLoaded = false)
public void onPlayerDisconnect(PlayerDisconnectEvent event) {
SkyBlockPlayer player = (SkyBlockPlayer) event.getPlayer();
if (!(HypixelConst.getTypeLoader() instanceof RaceInstance raceInstance)) {
return;
}
RaceManager race = raceInstance.getRace();
if (race == null) return;
if (!race.getPerPlayerStartTime().containsKey(player.getUuid())) return;
race.cancelRace(player);
}

@HypixelEvent(node = EventNodes.PLAYER, requireDataLoaded = true)
public void onPlayerMove(PlayerMoveEvent event) {
SkyBlockPlayer player = (SkyBlockPlayer) event.getPlayer();
if (!(HypixelConst.getTypeLoader() instanceof RaceInstance raceInstance)) {
return;
}
RaceManager race = raceInstance.getRace();

if (lastClickedTimes.containsKey(player.getUuid()) && lastClickedTimes.get(player.getUuid()) >= System.currentTimeMillis() - 500) return;
if (race == null) return;

Pos playerPos = event.getPlayer().getPosition();

if (playerPos.samePoint(race.getRace().startPosition(), 0.5)) {
if (!race.getPerPlayerStartTime().containsKey(player.getUuid()) || race.getPerPlayerStartTime().get(player.getUuid()).lastCheckpointIndex() == -1) {
player.playSound(Sound.sound(
Key.key("block.note_block.pling"), Sound.Source.NEUTRAL,
.3f, 0.75f
));

race.startRace(player);
lastClickedTimes.put(player.getUuid(), System.currentTimeMillis());
return;
}
}

for (int i = 0; i < race.getRace().getCheckpoints().size(); i++) {
if (playerPos.samePoint(race.getRace().getCheckpoints().get(i), 0.5)) {
race.checkpointPlayer(player, i);
lastClickedTimes.put(player.getUuid(), System.currentTimeMillis());
break;
}
}

if (playerPos.samePoint(race.getRace().endPosition(), 0.5)) {
race.finishedRace(player);
lastClickedTimes.put(player.getUuid(), System.currentTimeMillis());
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.swofty.type.skyblockgeneric.event.custom;

import lombok.AllArgsConstructor;
import lombok.Getter;
import net.minestom.server.entity.Player;
import net.minestom.server.event.trait.PlayerEvent;
import net.swofty.type.skyblockgeneric.race.Race;

@Getter
@AllArgsConstructor
public class ActionPlayerFinishRace implements PlayerEvent {

private final Player player;
private final Race race;
private final long time;

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.swofty.type.generic.gui.inventory.item.GUIClickableItem;
import net.swofty.type.generic.user.HypixelPlayer;
import net.swofty.type.skyblockgeneric.item.SkyBlockItem;
import net.swofty.type.skyblockgeneric.item.updater.NonPlayerItemUpdater;
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;

import java.util.List;
Expand Down Expand Up @@ -48,7 +49,7 @@ public void run(InventoryPreClickEvent e, HypixelPlayer p) {
@Override
public ItemStack.Builder getItem(HypixelPlayer player) {
return ItemStackCreator.appendLore(
new SkyBlockItem(rewardItem).getDisplayItem(),
new NonPlayerItemUpdater(new SkyBlockItem(rewardItem)).getUpdatedItem(),
List.of(
"",
"§eClick to claim!"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package net.swofty.type.skyblockgeneric.mission.missions.thepark.savanna;

import net.minestom.server.coordinate.Pos;
import net.swofty.commons.skyblock.item.ItemType;
import net.swofty.type.skyblockgeneric.gui.inventories.GUIClaimReward;
import net.swofty.type.skyblockgeneric.levels.SkyBlockLevelCause;
import net.swofty.type.skyblockgeneric.mission.LocationAssociatedMission;
import net.swofty.type.skyblockgeneric.mission.MissionData;
import net.swofty.type.skyblockgeneric.mission.SkyBlockMission;
import net.swofty.type.skyblockgeneric.mission.missions.thepark.birchpark.MissionClaimTheTrousers;
import net.swofty.type.skyblockgeneric.mission.missions.thepark.jungle.MissionTalkToMolbert;
import net.swofty.type.skyblockgeneric.mission.missions.thepark.spruce.MissionTalkToGustave;
import net.swofty.type.skyblockgeneric.region.RegionType;
import net.swofty.type.skyblockgeneric.skill.SkillCategories;
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
Expand Down Expand Up @@ -65,7 +61,6 @@ public void onEnd(SkyBlockPlayer player, Map<String, Object> customData, Mission
player.getSkills().increase(player, SkillCategories.FORAGING, 1500D);

player.getMissionData().startMission(MissionTalkToMolbert.class);
player.getMissionData().startMission(MissionTalkToGustave.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.swofty.type.skyblockgeneric.mission.MissionData;
import net.swofty.type.skyblockgeneric.mission.SkyBlockMission;
import net.swofty.type.skyblockgeneric.mission.missions.thepark.darkthicket.MissionTravelToTheDarkThicket;
import net.swofty.type.skyblockgeneric.mission.missions.thepark.spruce.race.MissionTalkToGustave;
import net.swofty.type.skyblockgeneric.region.RegionType;
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;

Expand Down Expand Up @@ -36,6 +37,7 @@ public Map<String, Object> onStart(SkyBlockPlayer player, MissionData.ActiveMiss
@Override
public void onEnd(SkyBlockPlayer player, Map<String, Object> customData, MissionData.ActiveMission mission) {
player.getMissionData().startMission(MissionTravelToTheDarkThicket.class);
player.getMissionData().startMission(MissionTalkToGustave.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package net.swofty.type.skyblockgeneric.mission.missions.thepark.spruce.race;

import net.swofty.type.skyblockgeneric.mission.MissionData;
import net.swofty.type.skyblockgeneric.mission.SkyBlockMission;
import net.swofty.type.skyblockgeneric.region.RegionType;
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;

import java.util.Map;
import java.util.Set;

public class MissionCompleteTheRaceFourth extends SkyBlockMission {

@Override
public String getID() {
return "run_the_race_18_seconds";
}

@Override
public String getName() {
return "Run the race in 18s";
}

@Override
public Map<String, Object> onStart(SkyBlockPlayer player, MissionData.ActiveMission mission) {
mission.getNewObjectiveText().forEach(player::sendMessage);
return Map.of();
}

@Override
public void onEnd(SkyBlockPlayer player, Map<String, Object> customData, MissionData.ActiveMission mission) {
player.getMissionData().startMission(MissionTalkToGustaveFifth.class);
}

@Override
public Set<RegionType> getValidRegions() {
return Set.of(RegionType.SPRUCE_WOODS, RegionType.DARK_THICKET, RegionType.SAVANNA_WOODLAND, RegionType.JUNGLE_ISLAND);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package net.swofty.type.skyblockgeneric.mission.missions.thepark.spruce.race;

import net.minestom.server.coordinate.Pos;
import net.swofty.type.skyblockgeneric.mission.LocationAssociatedMission;
import net.swofty.type.skyblockgeneric.mission.MissionData;
import net.swofty.type.skyblockgeneric.mission.SkyBlockMission;
import net.swofty.type.skyblockgeneric.region.RegionType;
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;

import java.util.Map;
import java.util.Set;

public class MissionCompleteTheRaceOneMinute extends SkyBlockMission {

@Override
public String getID() {
return "complete_the_race_one_minute";
}

@Override
public String getName() {
return "Run the race in 1m";
}

@Override
public Map<String, Object> onStart(SkyBlockPlayer player, MissionData.ActiveMission mission) {
mission.getNewObjectiveText().forEach(player::sendMessage);
return Map.of();
}

@Override
public void onEnd(SkyBlockPlayer player, Map<String, Object> customData, MissionData.ActiveMission mission) {
player.getMissionData().startMission(MissionTalkToGustaveAgainAgain.class);
}

@Override
public Set<RegionType> getValidRegions() {
return Set.of(RegionType.SPRUCE_WOODS, RegionType.DARK_THICKET, RegionType.SAVANNA_WOODLAND, RegionType.JUNGLE_ISLAND);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package net.swofty.type.skyblockgeneric.mission.missions.thepark.spruce.race;

import net.swofty.type.skyblockgeneric.mission.MissionData;
import net.swofty.type.skyblockgeneric.mission.SkyBlockMission;
import net.swofty.type.skyblockgeneric.region.RegionType;
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;

import java.util.Map;
import java.util.Set;

public class MissionCompleteTheRaceThird extends SkyBlockMission {

@Override
public String getID() {
return "run_the_race_32_seconds";
}

@Override
public String getName() {
return "Run the race in 32s";
}

@Override
public Map<String, Object> onStart(SkyBlockPlayer player, MissionData.ActiveMission mission) {
mission.getNewObjectiveText().forEach(player::sendMessage);
return Map.of();
}

@Override
public void onEnd(SkyBlockPlayer player, Map<String, Object> customData, MissionData.ActiveMission mission) {
player.getMissionData().startMission(MissionTalkToGustaveFourth.class);
}

@Override
public Set<RegionType> getValidRegions() {
return Set.of(RegionType.SPRUCE_WOODS, RegionType.DARK_THICKET, RegionType.SAVANNA_WOODLAND, RegionType.JUNGLE_ISLAND);
}
}
Loading