Latch v0.1.0 🔓

:unlock: Latch v0.1.0

Latch is a locking plugin allowing players to protect blocks like chests/furnaces/doors from being accessed by other players. v0.1.0 has been released as a late Christmas present to @Meronat!

Release / Source Code

Currently built against Sponge API 5.1.0 and API 6.0.0
You can download the latest release here
And view the source code here


  • 5 different types of locks
  • Public locks - anyone can access, just applies protection
  • Private locks - only players the owner adds can access
  • Password always locks - players with the password can access (required to type every time)
  • Password once locks - players with the password can access (only need to type the first time)
  • Donation locks - (applies to containers) only players the owner adds can withdraw, anyone can deposit
  • Lock protection from players, pistons, (optionally) explosions, (optionally) redstone
  • Configurable lock limits per type or total per player
  • Configurable lockable blocks
  • Locks saved to h2 database
  • Uses bstats for stat tracking

Known Issues / To Do

  ☐ Add admin capabilities to manage locks
  ☐ Add “Guild” lock type integrating with Guilds


latch.conf, stored in the /config/latch subdirectory

  • add_default_permissions - adds the “latch.normal” default permission as true
  • lockable_blocks - blocks that can be locked by players using this plugin
  • protect_from_explosives - should locks be protected from explosions
  • prevent_adjacent_to_locks - blocks to prevent being placed next to locks the player doesn’t own
  • Hopper here by default until Sponge adds necessary events to protect the locks
  • protect_below_block - locks that should also protect the block below them
  • Doors here by default until there’s some way to protect them when the block below is broken
  • lock_limit - limit for “total” locks per player, or per type of lock
  • public, private, password_always, password_once, donation
  • protect_from_redstone - allow locks to be protected from redstone


Latch uses Sponge’s short and long command flags for some commands.
-p can be added to most commands to persist the command after use.

  • /latch or /lock - base for most of the commands, displays plugin information
  • /latch help - list help for the commands
  • /latch private - create a private lock on the next block placed/clicked
  • /latch password [password] - creates a password lock with the given password (add below flag for different type)
    • -a - require a password every time to access (default)
    • -o - require a password once to access
  • /latch change - change the attributes of one of the locks you’re the owner of (add below flags, multiple flags can be used)
    • --type=[PRIVATE, PASSWORD_ALWAYS, PASSWORD_ONCE] - changes the lock type
    • --password=[password] - change the password of the lock (resets the access list)
    • --add=[player] - add the player to the lock access list (can have multiple within a single command)
    • --remove=[player] - remove the player from the lock access list (can have multiple within a single command)
    • --owner=[player] - gives the lock to another player
    • --redstone=[true/false] - prevent redstone interactions from occurring on this lock
  • /latch remove - remove a lock you’re the owner of
  • /latch persist - duplicates the functionality of the -p flag (persisting the last command typed)
  • Use again to turn off the command, or use /latch clear
  • /latch info or /latch display - display the lock name, owner, object and players that can access
  • /latch list - display all of your locks
  • /latch list [player] - to display all of a player’s locks (requires latch.admin.list permission)
  • /latch open [password] or /unlock [password] - to attempt to open a lock with the password
  • /latch add [user] or '/latch remove [user]` - modify the users allowed to access the lock


Each command has its own permission node under latch.normal (i.e. for the /latch info command).
Other permission categories below:

  • latch.normal - base for non-admin permissions/access
  • latch.normal.create - base for lock creation permissions
    • latch.normal.create.password.always - allows creation of a password_always lock
    • latch.normal.create.password.once - allows creation of a password_once lock
    • latch.normal.create.private - allows creation of a private lock
    • latch.normal.create.public - allows creation of a public lock
    • latch.normal.create.donation - allows creation of a donation lock
  • latch.admin - base for admin permissions/access
  • latch.admin.list - allows use of /latch list [player] to display a player’s locks

This looks very promising. May I ask, which SpongeAPI version is it built against?

Whoops meant to include this, it’s built against 5.0.0

Hello Night, will you be bringing any other database formats other than h2 in the near future?

I can definitely add them to the list. Is there a particular format you’re interested in?

mysql or sqlite would be perfect

Hello Night,

I noticed that /latch change --add (playername) does not appear to add the user to the locked list and it does out put a console error

Additionally there appears to be an issue when players use a password on the door that halts the server

Both errors are using latch v0.0.1 and Sponge 1.10.2-5.0.0-BETA-92, SpongeAPI 5.0.0-Snapshot-f8895a9

Thank you cellamir - this is fixed in v0.0.2, just uploaded it now.


Hello Night, sorry to bring more bad news.

It appears that when locking a door it locks in two different halves, as in the top half and bottom half of the door operate independently.

I can lock the top half of a door however anyone else can interact with the bottom half un affected by the locks

Thanks for reporting again Cellamir, this was working at one point but guess it broke :slight_smile:

I’ll try to fix this tomorrow.

Even if it’s a bug, that actually sounds like an interesting feature :wink:

… No, that’s not a suggestion to keep it. It just seems oddly useful.

1 Like

Evening Night,

I work with Cellamir on the same server. Seems the plugin is persisting with the error when using its commands.

Here is a log file from the server during the error in question.

And here is the Crash Report.

The error is occurring on Latch-0.0.2 on spongevanilla-1.10.2-5.0.0-BETA-99
Thank you again for your attention.

@Razor1rot and @cellamir

I’ve published v0.0.3 to resolve your issues, let me know if you notice anything else!


Much appreciated. thanks for the focused response. well check it out!

Running into a crash on boot when using Latch v0.0.3 on SpongeForge 5.0.0-BETA-1675. It seems like it can’t find the SqlService. Are you trying to use the service before it is registered?

Error injecting constructor, java.util.NoSuchElementException: No value present
	at com.ichorcommunity.latch.Latch.<init>(
	at org.spongepowered.common.guice.SpongePluginGuiceModule.configure(
	at org.spongepowered.mod.plugin.SpongeModPluginContainer.constructMod(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.fml.common.LoadController.redirect$onPost$0(
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(
	at net.minecraftforge.fml.common.Loader.loadMods(
	at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(
	at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(
	at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(
	at Source)
Caused by: java.util.NoSuchElementException: No value present
	at java.util.Optional.get(Unknown Source)
	at com.ichorcommunity.latch.Latch.<init>(
	at com.ichorcommunity.latch.Latch$$FastClassByGuice$$8fea1fb1.newInstance(<generated>)
	... 30 more

Thanks Kippers - I didn’t know Forge loaded things differently than Vanilla.

I’ve published v0.0.4 to initialize the SQL connection later and tested it with Forge, let me know if you have any other issues.

1 Like

Latch is working like a charm now, thanks.

Hi, The config file isn’t generating.

For me the configuration file is generating. Are you looking in the config folder? In there should be a folder called latch, and within there the configuration file is called latch.conf. If not, what version of Sponge are you using?

The folder is there but the latch.conf isn’t in there. the version of sponge i am using is spongeforge-1.10.2-2052-5.0.0-BETA-1675.jar