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

Added Dungeon Flow Events: #36

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
48 changes: 48 additions & 0 deletions src/main/java/io/github/skyblockcore/Dungeons.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.github.skyblockcore;

import java.util.HashMap;
import java.util.Map;

public class Dungeons {
public enum DUNGEON_FLOORS { UNDEFINED("UNDEFINED"), E("E"), F1("F1"), F2("F2"), F3("F3"), F4("F4"), F5("F5"), F6("F6"), F7("F7"), M1("M1"), M2("M2"), M3("M3"), M4("M4"), M5("M5"), M6("M6"), M7("M7");
private static final Map<String, DUNGEON_FLOORS> map = new HashMap<>();
private final String text;

static {
for(DUNGEON_FLOORS floor : DUNGEON_FLOORS.values()) {
map.put(floor.text, floor);
}
}

DUNGEON_FLOORS(String text) {
this.text = text;
}

public static DUNGEON_FLOORS fromString(String text) {
return map.get(text);
}

public DUNGEON_BOSSES getBoss() {
switch(this) {
case F1, M1: return DUNGEON_BOSSES.BONZO;
case F2, M2: return DUNGEON_BOSSES.SCARF;
case F3, M3: return DUNGEON_BOSSES.THE_PROFESSOR;
case F4, M4: return DUNGEON_BOSSES.THORN;
case F5, M5: return DUNGEON_BOSSES.LIVID;
case F6, M6: return DUNGEON_BOSSES.SADAN;
case F7, M7: return DUNGEON_BOSSES.WITHER_LORDS;
default: return DUNGEON_BOSSES.UNDEFINED;
}
}
}
public enum DUNGEON_BOSSES { UNDEFINED, BONZO, SCARF, THE_PROFESSOR, THORN, LIVID, SADAN, WITHER_LORDS }
public enum DUNGEON_CLASSES { HEALER, MAGE, BERSERK, ARCHER, TANK }

private static DUNGEON_FLOORS DUNGEON_FLOOR = null;
private static DUNGEON_BOSSES DUNGEON_BOSS = null;

public static DUNGEON_FLOORS getDungeonFloor() {return DUNGEON_FLOOR;}
public static void setDungeonFloor(DUNGEON_FLOORS floor) {DUNGEON_FLOOR = floor;}
public static DUNGEON_BOSSES getDungeonBoss() {return DUNGEON_BOSS;}
public static void setDungeonBoss(DUNGEON_BOSSES boss) {DUNGEON_BOSS = boss;}
}
61 changes: 55 additions & 6 deletions src/main/java/io/github/skyblockcore/SkyBlockCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.mojang.brigadier.CommandDispatcher;
import io.github.skyblockcore.command.SkyBlockCoreCommand;
import io.github.skyblockcore.event.*;
import io.github.skyblockcore.event.dungeons.*;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
Expand All @@ -40,18 +41,26 @@ public class SkyBlockCore implements ClientModInitializer {
public static final String SKYBLOCK_SCOREBOARD = "SBScoreboard";
public static final String HEALTH_SCOREBOARD = "health";
private static boolean ON_SKYBLOCK = false;
private static String LOCATION;
public static String getLocation() {
return LOCATION;
}
public static final Logger LOGGER = LoggerFactory.getLogger(ModID);

// Dungeons
private static boolean IN_DUNGEON = false;
private static boolean DUNGEON_ACTIVE = false;
public static boolean ENTERED_BOSSFIGHT = false;
public static Dungeons.DUNGEON_CLASSES DUNGEON_CLASS = Dungeons.DUNGEON_CLASSES.HEALER;

public static boolean isOnSkyblock() {
return ON_SKYBLOCK;
}

public static String getLocation() {
yourboykyle marked this conversation as resolved.
Show resolved Hide resolved
return LOCATION;
public static boolean isInDungeon() {return IN_DUNGEON;}
public static boolean isDungeonActive() {
return DUNGEON_ACTIVE;
}

private static String LOCATION;
public static final Logger LOGGER = LoggerFactory.getLogger(ModID);

public static final KeyBinding copyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"skyblockcore.dev.nbtcopy",
InputUtil.Type.KEYSYM,
Expand Down Expand Up @@ -90,6 +99,46 @@ public void onInitializeClient() {
return ActionResult.PASS;
}));

// Dungeons
EnterDungeonCallback.EVENT.register(() -> {
IN_DUNGEON = true;
ENTERED_BOSSFIGHT = false;
return ActionResult.PASS;
});
DungeonStartedCallback.EVENT.register((dungeonClass) -> {
DUNGEON_ACTIVE = true;
return ActionResult.PASS;
});
WitherKeyObtainedCallback.EVENT.register((obtainerUsername) -> {
if(obtainerUsername == null) return ActionResult.FAIL;
return ActionResult.PASS;
});
WitherDoorOpenedCallback.EVENT.register((openerUsername) -> {
if(openerUsername == null) return ActionResult.FAIL;
return ActionResult.PASS;
});
BloodKeyObtainedCallback.EVENT.register((obtainerUsername) -> {
if(obtainerUsername == null) return ActionResult.FAIL;
return ActionResult.PASS;
});
BloodDoorOpenedCallback.EVENT.register(() -> {
return ActionResult.PASS;
});
EnteredBossfightCallback.EVENT.register((boss) -> {
if(boss == null) return ActionResult.FAIL;
return ActionResult.PASS;
});
DungeonEndedCallback.EVENT.register((score) -> {
DUNGEON_ACTIVE = false;
return ActionResult.PASS;
});
LeaveDungeonCallback.EVENT.register(() -> {
IN_DUNGEON = false;
DUNGEON_ACTIVE = false;
ENTERED_BOSSFIGHT = false;
Dungeons.setDungeonBoss(null);
return ActionResult.PASS;
});
}

public static void registerCommands(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.skyblockcore.event.dungeons;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

public interface BloodDoorOpenedCallback {
Event<BloodDoorOpenedCallback> EVENT = EventFactory.createArrayBacked(BloodDoorOpenedCallback.class,
(listeners) -> () -> {
for (BloodDoorOpenedCallback listener : listeners) {
ActionResult result = listener.interact();

if (result != ActionResult.PASS) return result;
}
return ActionResult.PASS;
});

ActionResult interact();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.skyblockcore.event.dungeons;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

public interface BloodKeyObtainedCallback {
Event<BloodKeyObtainedCallback> EVENT = EventFactory.createArrayBacked(BloodKeyObtainedCallback.class,
(listeners) -> (obtainerUsername) -> {
for (BloodKeyObtainedCallback listener : listeners) {
ActionResult result = listener.interact(obtainerUsername);

if (result != ActionResult.PASS) return result;
}
return ActionResult.PASS;
});

ActionResult interact(String obtainerUsername);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.skyblockcore.event.dungeons;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

public interface DungeonEndedCallback {
Event<DungeonEndedCallback> EVENT = EventFactory.createArrayBacked(DungeonEndedCallback.class,
(listeners) -> (score) -> {
for (DungeonEndedCallback listener : listeners) {
ActionResult result = listener.interact(score);

if (result != ActionResult.PASS) return result;
}
return ActionResult.PASS;
});

ActionResult interact(int score);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.github.skyblockcore.event.dungeons;

import io.github.skyblockcore.Dungeons;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

public interface DungeonStartedCallback {
Event<DungeonStartedCallback> EVENT = EventFactory.createArrayBacked(DungeonStartedCallback.class,
(listeners) -> (dungeonClass) -> {
for (DungeonStartedCallback listener : listeners) {
ActionResult result = listener.interact(dungeonClass);

if (result != ActionResult.PASS) return result;
}
return ActionResult.PASS;
});

ActionResult interact(Dungeons.DUNGEON_CLASSES dungeonClass);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.skyblockcore.event.dungeons;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

public interface EnterDungeonCallback {
Event<EnterDungeonCallback> EVENT = EventFactory.createArrayBacked(EnterDungeonCallback.class,
(listeners) -> () -> {
for (EnterDungeonCallback listener : listeners) {
ActionResult result = listener.interact();

if (result != ActionResult.PASS) return result;
}
return ActionResult.PASS;
});

ActionResult interact();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.github.skyblockcore.event.dungeons;

import io.github.skyblockcore.Dungeons;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

public interface EnteredBossfightCallback {
Event<EnteredBossfightCallback> EVENT = EventFactory.createArrayBacked(EnteredBossfightCallback.class,
(listeners) -> (boss) -> {
for (EnteredBossfightCallback listener : listeners) {
ActionResult result = listener.interact(boss);

if (result != ActionResult.PASS) return result;
}
return ActionResult.PASS;
});

ActionResult interact(Dungeons.DUNGEON_BOSSES boss);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.skyblockcore.event.dungeons;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

public interface LeaveDungeonCallback {
Event<LeaveDungeonCallback> EVENT = EventFactory.createArrayBacked(LeaveDungeonCallback.class,
(listeners) -> () -> {
for (LeaveDungeonCallback listener : listeners) {
ActionResult result = listener.interact();

if (result != ActionResult.PASS) return result;
}
return ActionResult.PASS;
});

ActionResult interact();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.skyblockcore.event.dungeons;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

public interface WitherDoorOpenedCallback {
Event<WitherDoorOpenedCallback> EVENT = EventFactory.createArrayBacked(WitherDoorOpenedCallback.class,
(listeners) -> (openerUsername) -> {
for (WitherDoorOpenedCallback listener : listeners) {
ActionResult result = listener.interact(openerUsername);

if (result != ActionResult.PASS) return result;
}
return ActionResult.PASS;
});

ActionResult interact(String openerUsername);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.skyblockcore.event.dungeons;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

public interface WitherKeyObtainedCallback {
Event<WitherKeyObtainedCallback> EVENT = EventFactory.createArrayBacked(WitherKeyObtainedCallback.class,
(listeners) -> (obtainerUsername) -> {
for (WitherKeyObtainedCallback listener : listeners) {
ActionResult result = listener.interact(obtainerUsername);

if (result != ActionResult.PASS) return result;
}
return ActionResult.PASS;
});

ActionResult interact(String obtainerUsername);
}
Loading