Skip to content

Commit

Permalink
refactor: home module to support meta + update: github wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
sakurawald committed Jul 13, 2024
1 parent 7a72d0d commit d88f372
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/main/java/io/github/sakurawald/Fuji.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
// TODO: a program to generate module reference DAG
// TODO: powertool module
// TODO: refactor chat module to use prefix/suffix metas
// TODO: refactor home module to support metas


// TODO: refactor system-message module -> transform, supress
// TODO: add anti build module -> place, use, break, piston. (facility: alert, permission, black/white list)

public class Fuji implements ModInitializer {
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/io/github/sakurawald/config/model/ConfigModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class Quartz {
}

public Backup backup = new Backup();

public class Backup {
@Documentation("How many backup should we keep?")
public int max_slots = 15;
Expand Down Expand Up @@ -807,10 +808,15 @@ public class Extinguish {
public boolean enable = false;
}

@Documentation("This module provides `/home` command.")
@Documentation("""
This module provides `/home` command.
Meta:
- Integer `fuji.home.home_limit` # The home number per player limit.
""")

public class Home {
public boolean enable = false;
public int max_homes = 3;
}

@Documentation("This module provides `/ping` command.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
import io.github.sakurawald.util.MessageUtil;
import io.github.sakurawald.util.ScheduleUtil;
import lombok.Getter;
import me.lucko.fabric.api.permissions.v0.Options;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
Expand Down Expand Up @@ -102,7 +105,10 @@ private Map<String, Position> getHomes(ServerPlayerEntity player) {
MessageUtil.sendMessage(player, "home.set.fail.need_override", homeName);
return Command.SINGLE_SUCCESS;
}
} else if (name2position.size() >= Configs.configHandler.model().modules.home.max_homes) {
}

Optional<Integer> limit = Options.get(ctx.getSource(), "fuji.home.home_limit", Integer::valueOf);
if (limit.isPresent() && name2position.size() >= limit.get()) {
MessageUtil.sendMessage(player, "home.set.fail.limit");
return Command.SINGLE_SUCCESS;
}
Expand Down

0 comments on commit d88f372

Please sign in to comment.