Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup JDK 21
- name: Setup JDK 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
java-version: 25
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build artifacts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup JDK 21
- name: Setup JDK 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
java-version: 25
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build artifacts
Expand Down
24 changes: 15 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "fabric-loom" version "1.14-SNAPSHOT"
id "net.fabricmc.fabric-loom" version "1.15-SNAPSHOT"
}

version = project.mod_version
Expand All @@ -12,22 +12,28 @@ base {
repositories {
mavenCentral()

maven{
maven {
url = "https://maven.nucleoid.xyz/"
}

maven {
name = "eclipseisoffline"
url = "https://maven.eclipseisoffline.xyz/releases"
}
}

dependencies {
//to change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:${project.minecraft_version}")
mappings(loom.officialMojangMappings())
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")
implementation("net.fabricmc:fabric-loader:${project.loader_version}")

implementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")

modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
implementation(include("xyz.nucleoid:server-translations-api:${project.translation_version}"))
implementation(include("me.lucko:fabric-permissions-api:${project.permissions_api_version}"))
implementation(include("eu.pb4:common-protection-api:${project.protection_api_version}"))

modImplementation(include("xyz.nucleoid:server-translations-api:${project.translation_version}"))
modImplementation(include("me.lucko:fabric-permissions-api:${project.permissions_api_version}"))
modImplementation(include("eu.pb4:common-protection-api:${project.protection_api_version}"))
implementation(include("xyz.eclipseisoffline:filefixutils-fabric:${project.file_fix_utils_version}"))
}

processResources {
Expand All @@ -38,7 +44,7 @@ processResources {
}
}

def targetJavaVersion = 21
def targetJavaVersion = 25
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
Expand Down
15 changes: 8 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.11
loader_version=0.18.2
minecraft_version=26.1
loader_version=0.18.4

# Mod Properties
mod_version=1.2.2
mod_version=1.2.3
maven_group=us.potatoboy
archives_base_name=htm

# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.139.4+1.21.11
translation_version=2.5.2+1.21.9-pre3
permissions_api_version=0.6.1
protection_api_version=1.0.0
fabric_version=0.144.0+26.1
translation_version=3.0.1+26.1
permissions_api_version=0.7.0
protection_api_version=2.0.0
file_fix_utils_version=0.1.3-26.1
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/main/java/com/github/fabricservertools/htm/HTM.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.apache.logging.log4j.Logger;

public class HTM implements ModInitializer {
public static final String MOD_ID = "htm";
public static final Logger LOGGER = LogManager.getLogger("HTM");

@Override
Expand All @@ -25,9 +26,13 @@ public void onInitialize() {

HTMCommand.bootstrap();
CommandRegistrationCallback.EVENT.register(((dispatcher, buildContext, selection) -> HTMCommand.register(dispatcher)));
CommonProtection.register(Identifier.fromNamespaceAndPath("htm", "containers"), new InteractionManager());
CommonProtection.register(getModdedIdentifier("containers"), new InteractionManager());

PlayerEventListener.init();
LevelEventListener.init();
}

public static Identifier getModdedIdentifier(String path) {
return Identifier.fromNamespaceAndPath(MOD_ID, path);
}
}
15 changes: 15 additions & 0 deletions src/main/java/com/github/fabricservertools/htm/HTMFileFixes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.fabricservertools.htm;

import net.minecraft.resources.Identifier;
import xyz.eclipseisoffline.filefixutils.api.FileFixHelpers;
import xyz.eclipseisoffline.filefixutils.api.FileFixInitializer;

public class HTMFileFixes implements FileFixInitializer {

@Override
public void onFileFixPopulate() {
// This needs to be in its own class, using as little other classes as possible, to prevent accidentally running static initialisers
// this early in the game loading process
FileFixHelpers.registerGlobalDataMoveFileFix("globalTrust", Identifier.fromNamespaceAndPath("htm", "global_trust_data"));
}
}
14 changes: 1 addition & 13 deletions src/main/java/com/github/fabricservertools/htm/Utility.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.github.fabricservertools.htm;

import com.github.fabricservertools.htm.interactions.InteractionManager;
import com.github.fabricservertools.htm.world.data.GlobalTrustData;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.players.NameAndId;
import net.minecraft.world.entity.player.Player;
import java.util.UUID;

public class Utility {
Expand All @@ -22,16 +20,6 @@ public static Component getFormattedNameFromUUID(UUID uuid, MinecraftServer serv
}

public static GlobalTrustData getGlobalTrustData(MinecraftServer server) {
return server.overworld().getDataStorage().computeIfAbsent(GlobalTrustData.TYPE);
}

public static void sendMessage(Player player, Component message) {
sendMessage(player, message, false);
}

public static void sendMessage(Player player, Component message, boolean actionBar) {
if (!InteractionManager.noMessage.contains(player.getUUID())) {
player.displayClientMessage(message, actionBar);
}
return server.getDataStorage().computeIfAbsent(GlobalTrustData.TYPE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private int trustList(CommandContext<CommandSourceStack> context) throws Command
.map(uuid -> Utility.getNameFromUUID(uuid, context.getSource().getServer()))
.collect(Collectors.joining(", "));

player.displayClientMessage(HTMComponents.TRUSTED_GLOBALLY.apply(Component.literal(trustedList).withStyle(ChatFormatting.WHITE)), false);
player.sendSystemMessage(HTMComponents.TRUSTED_GLOBALLY.apply(Component.literal(trustedList).withStyle(ChatFormatting.WHITE)));

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,20 @@ public FlagAction(Optional<Pair<FlagType, @Nullable Boolean>> flagSet) {
@Override
public void execute(MinecraftServer server, ServerPlayer player, BlockPos pos, LockableObject object, HTMContainerLock lock) {
if (!lock.isOwner(player)) {
player.displayClientMessage(HTMComponents.NOT_OWNER, false);
player.sendSystemMessage(HTMComponents.NOT_OWNER);
return;
}

BlockState state = player.level().getBlockState(pos);
if (flagSet.isEmpty()) {
//flag info
player.displayClientMessage(HTMComponents.DIVIDER, false);
player.sendSystemMessage(HTMComponents.DIVIDER);
lock.flags().forEach(state, (flag, value) -> {
player.displayClientMessage(HTMComponents.CONTAINER_FLAG.apply(
player.sendSystemMessage(HTMComponents.CONTAINER_FLAG.apply(
flag.displayName(),
Component.literal(value.toString().toUpperCase()).withStyle(value ? ChatFormatting.GREEN : ChatFormatting.RED, ChatFormatting.BOLD)),
false);
Component.literal(value.toString().toUpperCase()).withStyle(value ? ChatFormatting.GREEN : ChatFormatting.RED, ChatFormatting.BOLD)));
});
player.displayClientMessage(HTMComponents.DIVIDER, false);
player.sendSystemMessage(HTMComponents.DIVIDER);
} else {
//flag set
FlagType flagType = flagSet.get().getFirst();
Expand All @@ -70,7 +69,7 @@ public void execute(MinecraftServer server, ServerPlayer player, BlockPos pos, L
feedback = HTMComponents.CONTAINER_FLAG_SET;
feedbackValue = value;
}
player.displayClientMessage(feedback.apply(
player.sendSystemMessage(feedback.apply(
flagType.displayName(),
Component.literal(String.valueOf(feedbackValue).toUpperCase()).withStyle(feedbackValue ? ChatFormatting.GREEN : ChatFormatting.RED, ChatFormatting.BOLD)),
false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ public void execute(MinecraftServer server, ServerPlayer player, BlockPos pos, L
return;
}

player.displayClientMessage(HTMComponents.DIVIDER, false);
player.displayClientMessage(HTMComponents.CONTAINER_LOCK_TYPE.apply(lock.lockData().displayName()), false);
player.displayClientMessage(HTMComponents.CONTAINER_OWNER.apply(Component.literal(owner.get().name()).withStyle(ChatFormatting.WHITE)), false);
player.sendSystemMessage(HTMComponents.DIVIDER);
player.sendSystemMessage(HTMComponents.CONTAINER_LOCK_TYPE.apply(lock.lockData().displayName()));
player.sendSystemMessage(HTMComponents.CONTAINER_OWNER.apply(Component.literal(owner.get().name()).withStyle(ChatFormatting.WHITE)));
if (lock.isOwner(player)) {
String trustedList = lock.trusted()
.stream()
.map(uuid -> Utility.getNameFromUUID(uuid, server))
.collect(Collectors.joining(", "));

player.displayClientMessage(HTMComponents.CONTAINER_TRUSTED.apply(Component.literal(trustedList).withStyle(ChatFormatting.WHITE)), false);
player.sendSystemMessage(HTMComponents.CONTAINER_TRUSTED.apply(Component.literal(trustedList).withStyle(ChatFormatting.WHITE)));
lock.lockData().onInfo(player, lock);
}
player.displayClientMessage(HTMComponents.DIVIDER, false);
player.sendSystemMessage(HTMComponents.DIVIDER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.fabricservertools.htm.HTMComponents;
import com.github.fabricservertools.htm.api.LockInteraction;
import com.github.fabricservertools.htm.api.LockableObject;
import com.mojang.authlib.GameProfile;
import eu.pb4.common.protection.api.ProtectionProvider;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
Expand All @@ -14,6 +13,7 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.NameAndId;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.ChestBlock;
Expand Down Expand Up @@ -96,12 +96,12 @@ public static void execute(MinecraftServer server, ServerPlayer player, BlockPos
if (action.requiresLock()) {
containerLock.ifPresentOrElse(
lock -> action.execute(server, player, pos, object, lock),
() -> player.displayClientMessage(HTMComponents.NOT_LOCKED, false));
() -> player.sendSystemMessage(HTMComponents.NOT_LOCKED));
} else {
//noinspection DataFlowIssue - if requiresLock is false then action should be able to accept null lock
action.execute(server, player, pos, object, containerLock.orElse(null));
}
}, () -> player.displayClientMessage(HTMComponents.NOT_LOCKABLE, false));
}, () -> player.sendSystemMessage(HTMComponents.NOT_LOCKABLE));

if (!persisting.contains(player.getUUID())) {
pendingActions.remove(player);
Expand Down Expand Up @@ -184,7 +184,7 @@ public boolean isProtected(Level world, BlockPos pos) {
}

@Override
public boolean canBreakBlock(Level world, BlockPos pos, GameProfile profile, @Nullable Player player) {
public boolean canBreakBlock(Level world, BlockPos pos, NameAndId profile, @Nullable Player player) {
var lockable = InteractionManager.getLockable((ServerLevel) world, pos);
return lockable.flatMap(LockableObject::getLock).map(lock -> lock.owner().equals(profile.id())).orElse(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public class RemoveAction implements LockInteraction {
@Override
public void execute(MinecraftServer server, ServerPlayer player, BlockPos pos, LockableObject object, HTMContainerLock lock) {
if (!lock.isOwner(player)) {
player.displayClientMessage(HTMComponents.NOT_OWNER, false);
player.sendSystemMessage(HTMComponents.NOT_OWNER);
return;
}

object.setLock(null);
player.displayClientMessage(HTMComponents.CONTAINER_UNLOCKED, false);
player.sendSystemMessage(HTMComponents.CONTAINER_UNLOCKED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public SetAction(Lock setType) {
@Override
public void execute(MinecraftServer server, ServerPlayer player, BlockPos pos, LockableObject object, @Nullable HTMContainerLock lock) {
if (lock != null && !lock.isOwner(player)) {
player.displayClientMessage(HTMComponents.NOT_OWNER, false);
player.sendSystemMessage(HTMComponents.NOT_OWNER);
return;
}

HTMContainerLock newLock = lock != null ? lock.withData(setType) : new HTMContainerLock(setType, player);
object.setLock(newLock);
player.displayClientMessage(HTMComponents.CONTAINER_SET.apply(setType.displayName()), false);
player.sendSystemMessage(HTMComponents.CONTAINER_SET.apply(setType.displayName()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ public TransferAction(NameAndId transferPlayer) {
@Override
public void execute(MinecraftServer server, ServerPlayer player, BlockPos pos, LockableObject object, HTMContainerLock lock) {
if (!lock.isOwner(player)) {
player.displayClientMessage(HTMComponents.NOT_OWNER, false);
player.sendSystemMessage(HTMComponents.NOT_OWNER);
return;
}

if (lock.owner().equals(transferPlayer.id())) {
player.displayClientMessage(HTMComponents.CANNOT_TRUST_SELF, false);
player.sendSystemMessage(HTMComponents.CANNOT_TRUST_SELF);
return;
}

object.setLock(lock.transfer(transferPlayer.id()));
player.displayClientMessage(HTMComponents.CONTAINER_TRANSFER.apply(Component.literal(transferPlayer.name()).withStyle(ChatFormatting.WHITE)), false);
player.sendSystemMessage(HTMComponents.CONTAINER_TRANSFER.apply(Component.literal(transferPlayer.name()).withStyle(ChatFormatting.WHITE)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ public TrustAction(Collection<NameAndId> trustPlayers, boolean untrust) {
@Override
public void execute(MinecraftServer server, ServerPlayer player, BlockPos pos, LockableObject object, HTMContainerLock lock) {
if (!lock.isOwner(player)) {
player.displayClientMessage(HTMComponents.NOT_OWNER, false);
player.sendSystemMessage(HTMComponents.NOT_OWNER);
return;
}

for (NameAndId trustPlayer : trustPlayers) {
if (lock.owner().equals(trustPlayer.id())) {
player.displayClientMessage(HTMComponents.CANNOT_TRUST_SELF, false);
player.sendSystemMessage(HTMComponents.CANNOT_TRUST_SELF);
continue;
}

Component playerName = Component.literal(trustPlayer.name()).withStyle(ChatFormatting.WHITE);
if (untrust) {
lock.withoutTrusted(trustPlayer.id()).ifPresentOrElse(newLock -> {
player.displayClientMessage(HTMComponents.UNTRUST.apply(playerName), false);
player.sendSystemMessage(HTMComponents.UNTRUST.apply(playerName));
object.setLock(newLock);
}, () -> player.displayClientMessage(HTMComponents.PLAYER_NOT_TRUSTED.apply(playerName), false));
}, () -> player.sendSystemMessage(HTMComponents.PLAYER_NOT_TRUSTED.apply(playerName)));
} else {
lock.withTrusted(trustPlayer.id()).ifPresentOrElse(newLock -> {
player.displayClientMessage(HTMComponents.TRUST.apply(playerName), false);
player.sendSystemMessage(HTMComponents.TRUST.apply(playerName));
object.setLock(newLock);
}, () -> player.displayClientMessage(HTMComponents.ALREADY_TRUSTED.apply(playerName), false));
}, () -> player.sendSystemMessage(HTMComponents.ALREADY_TRUSTED.apply(playerName)));
}
}
}
Expand Down
Loading
Loading