Skip to content

Commit

Permalink
Adapt to FTB Teams API changes and disable FTB Quests integration unt…
Browse files Browse the repository at this point in the history
…il it's released for 1.20. Fixes #555
  • Loading branch information
Technici4n committed Aug 24, 2023
1 parent 354b6d5 commit 5b9188e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ dependencies {
}

// TODO 1.20: FTB stuff
modCompileOnly("dev.ftb.mods:ftb-quests-fabric:${project.ftb_quests_version}") {
// modCompileOnly("dev.ftb.mods:ftb-quests-fabric:${project.ftb_quests_version}") {
// exclude(group: "net.fabricmc.fabric-api")
// exclude(group: "me.shedaniel")
// }
modImplementation("dev.ftb.mods:ftb-teams-fabric:${project.ftb_teams_version}") {
exclude(group: "net.fabricmc.fabric-api")
exclude(group: "me.shedaniel")
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ org.gradle.jvmargs=-Xmx1G \
ae2_version=15.0.7-beta
no_indium_version=1.1.0+1.20
ftb_quests_version=1902.4.16-build.235
ftb_teams_version=2001.1.4
kubejs_version=2001.6.2-build.4

# Set to "rei", "jei", or "emi" to pick which tooltip mod gets picked at runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,32 @@
*/
package aztech.modern_industrialization.compat.ftbquests;

import dev.ftb.mods.ftbquests.item.MissingItem;
import dev.ftb.mods.ftbquests.quest.ServerQuestFile;
import dev.ftb.mods.ftbquests.quest.task.ItemTask;
import dev.ftb.mods.ftbteams.FTBTeamsAPI;
import java.util.UUID;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

public class FTBQuestsFacadeImpl implements FTBQuestsFacade {
@Override
public void addCompleted(UUID uuid, Item item, long amount) {
var file = ServerQuestFile.INSTANCE;
var data = file.getNullableTeamData(FTBTeamsAPI.getPlayerTeamID(uuid));

if (data == null || data.isLocked()) {
return;
}

ItemStack stack = new ItemStack(item, (int) amount);

for (var task : file.getSubmitTasks()) {
if (task instanceof ItemTask itemTask && data.canStartTasks(task.quest)) {
if (data.isCompleted(task) || itemTask.item.getItem() instanceof MissingItem || item instanceof MissingItem) {
continue;
}

if (!task.consumesResources() && itemTask.test(stack)) {
data.addProgress(task, amount);
}
}
}
// TODO 1.20: wait for FTB Quests update
// var file = ServerQuestFile.INSTANCE;
// var data = file.getNullableTeamData(FTBTeamsAPI.getPlayerTeamID(uuid));
//
// if (data == null || data.isLocked()) {
// return;
// }
//
// ItemStack stack = new ItemStack(item, (int) amount);
//
// for (var task : file.getSubmitTasks()) {
// if (task instanceof ItemTask itemTask && data.canStartTasks(task.quest)) {
// if (data.isCompleted(task) || itemTask.item.getItem() instanceof MissingItem || item instanceof MissingItem) {
// continue;
// }
//
// if (!task.consumesResources() && itemTask.test(stack)) {
// data.addProgress(task, amount);
// }
// }
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
package aztech.modern_industrialization.compat.ftbteams;

import dev.ftb.mods.ftbteams.FTBTeamsAPI;
import dev.ftb.mods.ftbteams.event.TeamEvent;
import dev.ftb.mods.ftbteams.api.FTBTeamsAPI;
import dev.ftb.mods.ftbteams.api.event.TeamEvent;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand All @@ -46,12 +46,13 @@ public FTBTeamsFacadeImpl() {
@Override
public Iterable<UUID> getOtherPlayersInTeam(UUID playerUuid) {
return cachedPlayersInTeam.computeIfAbsent(playerUuid, uuid -> {
var team = FTBTeamsAPI.getManager().getPlayerTeam(uuid);
if (team == null) {
// Not supposed to happen, but just in case...
var team = FTBTeamsAPI.api().getManager().getTeamForPlayerID(uuid);
if (team.isEmpty()) {
// Can happen if the uuid is unknown,
// for example if ftb teams was installed after the fact and this player never logged in since
return List.of();
}
var keys = new HashSet<>(team.getMembers());
var keys = new HashSet<>(team.get().getMembers());
keys.remove(uuid);
return keys;
});
Expand Down

0 comments on commit 5b9188e

Please sign in to comment.