All Projects → rutgerkok → BlockLocker

rutgerkok / BlockLocker

Licence: MIT license
Protect chests, doors and other blocks in Minecraft from being opened using protection signs

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to BlockLocker

AntiCheatReloaded
The free anti-cheat since 2016
Stars: ✭ 94 (+135%)
Mutual labels:  spigot-plugin, minecraft-plugin
CommandWhitelist
You decide what commands players can use or tab complete on your server!
Stars: ✭ 115 (+187.5%)
Mutual labels:  spigot-plugin, minecraft-plugin
oraxen
Oraxen is a minecraft plugin that allows to easily use Minecraft 1.14 features in order to create new items with custom textures. It handles the resourcepack generation, upload (using Polymath) and has an extensible API.
Stars: ✭ 358 (+795%)
Mutual labels:  spigot-plugin, minecraft-plugin
MinetopiaVehicles
A realistic vehicle plugin for your Minecraft server!
Stars: ✭ 52 (+30%)
Mutual labels:  spigot-plugin, minecraft-plugin
UltiTools
This is a sum of some basic plugins of a Bukkit server or Spigot server. Including a few useful and creative functions.
Stars: ✭ 17 (-57.5%)
Mutual labels:  spigot-plugin, minecraft-plugin
MinecraftManhunt
Minecraft Bukkit plugin to run Manhunt minigames, with Discord music integration
Stars: ✭ 20 (-50%)
Mutual labels:  spigot-plugin, minecraft-plugin
pyplugins
Python Plugins loader plugin for Minecraft Spigot (Jython)
Stars: ✭ 25 (-37.5%)
Mutual labels:  spigot-plugin, minecraft-plugin
grakkit
A modern JavaScript development environment for Minecraft.
Stars: ✭ 184 (+360%)
Mutual labels:  spigot-plugin, minecraft-plugin
McRPG
An RPG plugin for Minecraft 1.13
Stars: ✭ 32 (-20%)
Mutual labels:  spigot-plugin, minecraft-plugin
EliteMobs
This is a spigot plugin that aims to extend Minecraft's survival endgame by making mobs more interesting.
Stars: ✭ 114 (+185%)
Mutual labels:  spigot-plugin, minecraft-plugin
NativeScreen
Spigot plugin that displays your desktop content and videos using Minecraft's maps.
Stars: ✭ 31 (-22.5%)
Mutual labels:  spigot-plugin, minecraft-plugin
advanced-region-market
A Bukkit/Spigot plugin for renting/selling WorldGuard regions
Stars: ✭ 40 (+0%)
Mutual labels:  spigot-plugin, minecraft-plugin
TabTPS
Minecraft server mod/plugin to monitor TPS, MSPT, and other information in the tab menu, boss bar, and action bar.
Stars: ✭ 151 (+277.5%)
Mutual labels:  spigot-plugin, minecraft-plugin
SquidGame
Minecraft Minigame inspired by the famous and trending Netflix series "Squid Game"
Stars: ✭ 36 (-10%)
Mutual labels:  spigot-plugin, minecraft-plugin
HeadsPlus
A heads plugin that has grown for over two years into something more ambitious than other plugins.
Stars: ✭ 35 (-12.5%)
Mutual labels:  spigot-plugin, minecraft-plugin
MarriageMaster
Marriage Plugin for Bukkit/Spigot
Stars: ✭ 79 (+97.5%)
Mutual labels:  spigot-plugin, minecraft-plugin
Islands
A spigot plugin for creating customisable home islands with different biomes. https://www.spigotmc.org/resources/islands-home-islands-system.84303/
Stars: ✭ 18 (-55%)
Mutual labels:  spigot-plugin, minecraft-plugin
BetterSleeping
A Spigot plugin that will make sleeping on servers less of a hassle
Stars: ✭ 67 (+67.5%)
Mutual labels:  spigot-plugin, minecraft-plugin
Minecraft QQ
一个用于Minecraft服务器与QQ群互联的插件
Stars: ✭ 19 (-52.5%)
Mutual labels:  spigot-plugin, minecraft-plugin
hyperblock
[DEPRECATED] A theoretically-infinitely-scalable Skyblock plugin.
Stars: ✭ 16 (-60%)
Mutual labels:  spigot-plugin, minecraft-plugin

BlockLocker

Build Status Download at SpigotMC.org Latest release Commits since latest release

Lockette/Deadbolt clone that properly supports UUIDs (and the new doors), written from scratch.

Current features:

  • Locks chests, furnaces, doors and a few other containers using the familiar [Private] and [More Users] signs.
  • Signs placed against a container are automatically filled with [Private] and the name of the player.
  • Only the owner of a protection can destroy a protection.
  • Admins can still open protected doors and containers.
  • UUID support
    • UUIDs are saved to hidden hover text data on the sign, never visible for users.
    • Automatically looks up UUIDs for signs from Lockette and Deadbolt when they are read.
  • Fully configurable
    • All messages can be translated.
    • You can change which block types can be protected. Even more complex blocks like levers work correctly.
  • Group support: adding [MyGroup] to the sign will allow anyone with the permission node blocklocker.group.mygroup (grant the lowercase node) and anyone in a scoreboard team or in a faction of MassiveCraft Factions called MyGroup (case insensitive).
  • Correctly handles complex blocks:
    • Double door support: protecting one half also protects the other half, opening one half opens the other half.
    • Doors can be set to close automatically. BlockLocker does not just toggle the open state, it will actually close the door.
    • Double chest support: protecting one half also proects the other half.
    • Trapdoor support: the sign can be attached to either the "hinge"-block or the trapdoor itself.
    • Fence gate support: the sign can be attached to either the the fence gate block or the block below.
  • The owner of a protection can change the signs after creating them using the /blocklocker <line number> <name> command.
  • Auto-updater, so that you are notified when there is a new version available.

Compilation

BlockLocker uses Maven.

  • Install Maven 3
  • Download this repo and run the command mvn clean install

After running the command there will be a file blocklocker-XX.jar (where XX is a version number) in the target folder.

Hooking into BlockLocker

BlockLocker has two APIs for other plugins to use: version 1 and version 2. Right now, the only difference between them is that version 1 uses com.google.common.base.Optional while version 2 uses java.util.Optional. Version 1 was first included in BlockLocker 0.1, and the plan is to include it in all future versions of BlockLocker as long as the class com.google.common.base.Optional exists. Version 2 was realeased on November 17, 2019 with BlockLocker 1.7.

  • If your plugin supports Minecraft 1.14, chances are that people are still using BlockLocker 1.6, and you should use API version 1.
  • If your plugin supports Minecraft 1.13 or older, you'll have to use API version 1, as version 2 is not available for Minecraft 1.13.
  • If your plugin only supports Minecraft 1.15 and newer, then you can safely use API version 2.

Maven

Add the following repository to your pom.xml file:

<repository>
	<id>codemc-repo</id>
	<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>

Add the following file:

<dependency>
	<groupId>nl.rutgerkok</groupId>
	<artifactId>blocklocker</artifactId>
	<version>1.9</version>
	<scope>provided</scope>
</dependency>

If you want to use API version 1, use BlockLocker version 0.1, otherwise for API version 2 use BlockLocker 1.7. Other BlockLocker versions are not uploaded to this repository.

Check whether the plugin is enabled

boolean enabled = Bukkit.getPluginManager().getPlugin("BlockLocker") != null;

The BlockLockerAPI - version 1

The nice thing about API version 1 is that it works with all old BlockLocker versions, all the way back to version 0.1. Version 1 still uses the com.google.common.base.Optional class. Because Java 8 also includes an Optional class, it can be expected that Google's Optional will be removed at some point in the future. At this moment, this API will also dissappear. However, currently the Optional class is not deprecated by Google, so it will take at least two years for that class to get removed. So it's still safe to use this API.

Example usage:

Optional<OfflinePlayer> owner = BlockLockerAPI.getOwner(block);

In version 0.1 these methods were available in the BlockLockerAPI class:

getOwner(Block block)
getOwnerDisplayName(Block block)
isAllowed(Player player, Block block, boolean serverAdminsAlwaysAllowed)
isOwner(Player player, Block block)
isProtected(Block block)

You can view the complete class, along with documentation, here.

If you solely use these methods, your plugin will work with all versions of BlockLocker from the past.

The BlockLockerAPI - version 2

Use the class BlockLockerAPIv2 instead of BlockLockerAPI. There are no differences between version 2 and version 1 yet, except that the API now uses java.util.Optional instead of the older com.google.common.base.Optional.

More advanced functionality

To block placement of protection signs in certain areas, you can listen to the PlayerProtectionCreateEvent of BlockLocker or the BlockPlaceEvent of Bukkit. This works even for auto-placed signs.

I have kept the number of methods in BlockLockerAPI small, as each method will need to be around in all future versions of BlockLocker. If you need to do something more advanced, you need to venture outside the class. Keep in mind that your plugin might break in the future. Here are some things that you can do.

Here's an example for checking whether redstone is allowed in the protection:

private boolean isRedstoneAllowed(Block block) {
    BlockLockerPlugin plugin = BlockLockerAPIv2.getPlugin();
    Optional<Protection> protection = plugin.getProtectionFinder().findProtection(block);
    if (!protection.isPresent()) {
        // Not protected, so redstone is allowed to change things here
        return true;
    }
    Profile redstoneProfile = plugin.getProfileFactory().fromRedstone();
    // Will return true when [Redstone] or [Everyone] is on one of the signs
    return protection.get().isAllowed(redstoneProfile);
}

Here's an example of how to add a custom group system:

BlockLockerAPIv2.getPlugin().getGroupSystems().addSystem(new GroupSystem() {

            @Override
            public boolean isInGroup(Player player, String groupName) {
                // TODO Auto-generated method stub
                return false;
            }});

Here's an example of how to add another block type as a protectable type:

    BlockLockerAPIv2.getPlugin().getChestSettings().getExtraProtectables().add(new ProtectableBlocksSettings() {

            @Override
            public boolean canProtect(Block block) {
                // Return whether the block can be protected by ANY of the protection types (CONTAINER, DOOR, etc.)
		// Must be consistent with the method below
                return false;
            }

            @Override
            public boolean canProtect(ProtectionType type, Block block) {
                // Return whether the block can be protected by the given protection types (CONTAINER, DOOR, etc.)
		// Must be consistent with the method above
                return false;
            }});

If you believe that a method should be added to BlockLockerAPI, please create a Github issue in this repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].