Skip to content

Commit

Permalink
Merge pull request #112 from josemmo/develop
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
josemmo authored Jan 6, 2024
2 parents 347ab60 + b0f6330 commit 17c59ea
Show file tree
Hide file tree
Showing 34 changed files with 1,445 additions and 803 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,19 @@ jobs:
echo "Plugin did not enabled verbose mode"
exit 1
fi
if ! grep -Fq '[YamipaPlugin] Found 5 file(s) in images directory' server.log; then
if ! grep -Fq '[YamipaPlugin] [ImageStorage] Found 5 file(s) in images directory' server.log; then
echo "Plugin did not read image directory"
exit 1
fi
if ! grep -Fq '[YamipaPlugin] Fixed command permissions' server.log; then
if ! grep -Fq '[YamipaPlugin] [ImageCommandBridge] Fixed command permissions' server.log; then
echo "Plugin did not fixed command permissions"
exit 1
fi
if ! grep -Fq '[YamipaPlugin] Created FakeImage' server.log; then
if ! grep -Fq '[YamipaPlugin] [FakeImage] Created FakeImage' server.log; then
echo "Plugin did not place the fake image"
exit 1
fi
if ! grep -Fq '[YamipaPlugin] Invalidated FakeImage' server.log; then
if ! grep -Fq '[YamipaPlugin] [FakeImage] Invalidated FakeImage' server.log; then
echo "Plugin did not remove the fake image"
exit 1
fi
Expand Down
81 changes: 69 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,50 @@ Yamipa is ready-to-go right out of the box. By default, it creates the following
- `images.dat`: A file holding the list and properties (e.g. coordinates) of all placed images in your server. You
shouldn't modify its contents.

You can change the default path of these files by creating a `config.yml` file in the plugin configuration directory:
You can change the path of these files by creating a `config.yml` file in the plugin configuration directory.
Here are the default configuration values if you don't specify them:
```yaml
verbose: false # Set to "true" to enable more verbose logging
animate-images: true # Set to "false" to disable GIF support
images-path: images # Path to images directory
cache-path: cache # Path to cache directory
data-path: images.dat # Path to placed images database file
verbose: false # Set to "true" to enable more verbose logging
animate-images: true # Set to "false" to disable GIF support
images-path: images # Path to images directory
cache-path: cache # Path to cache directory
data-path: images.dat # Path to placed images database file
allowed-paths: null # Set to a RegExp to limit accessible images to players
max-image-dimension: 30 # Maximum width or height in blocks allowed in images
```
For more information on how to set a different `allowed-paths` or `max-image-dimension` value per player, see the
[Player variables](#player-variables) section.

### Allowed paths
The variable `allowed-paths` is a regular expression that determines whether a player is allowed to see or download
an image file. If the desired path relative to the images directory matches this expression, then the player is allowed
to continue.

If `allowed-paths` is an empty string ("") or null, then the player can read any image file or download to any path
inside the images directory.

This regular expression must follow
[the syntax used by Java](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html). You can test your
expression beforehand using an online tool like [regex101](https://regex101.com/).
In addition, you can make use of the following special tokens:

- `#player#`: Player name
- `#uuid#`: Player UUID (with hyphens)

For example, if you want every player in your server to have their own subdirectory for storing files that only they
can access, plus a shared public directory, you can use the following `allowed-paths` value:
```regexp
^(private/#player#|public)/
```

That way, the player "john" can see the image file at "private/john/something.jpg", but "jane" cannot.

> **IMPORTANT!**\
> Note that these restrictions **also apply to other entities** like NPCs, command blocks or the server console.
> However, special tokens will always match in non-player contexts (e.g., "#player#" will be interpreted as ".+").

### bStats
This library uses bStats to anonymously report the number of installs. If you don't like this, feel free to
disable it at any time by adding `enabled: false` to the
[bStats configuration file](https://bstats.org/getting-started#:~:text=Disabling%20bStats) (it's ok, no hard feelings).
Expand All @@ -75,17 +110,17 @@ This plugin adds the following commands:
- Show help\
`/image`
- Download an image from a URL and save it with another name\
`/image download "https://www.example.com/a/b/c/1234.jpg" imagename.jpg`
`/image download "https://www.example.com/a/b/c/1234.jpg" "imagename.jpg"`
- Give 10 image items to "TestPlayer" for the "test.jpg" image (3x5 blocks)\
`/image give TestPlayer test.jpg 10 3 5`
`/image give TestPlayer "test.jpg" 10 3 5`
- Give 10 image items to "TestPlayer" that will not drop an image item when removed\
`/image give TestPlayer test.jpg 10 3 5 -DROP`
`/image give TestPlayer "test.jpg" 10 3 5 -DROP`
- Start the dialog to place an image with a width of 3 blocks and auto height\
`/image place imagename.jpg 3`
`/image place "imagename.jpg" 3`
- Start the dialog to place a 3-blocks wide and 2-blocks high image\
`/image place imagename.jpg 3 2`
`/image place "imagename.jpg" 3 2`
- Start the dialog to place an image that glows in the dark\
`/image place imagename.jpg 3 2 +GLOW`
`/image place "imagename.jpg" 3 2 +GLOW`
- Start the dialog to remove a placed image while keeping the original file\
`/image remove`
- Remove all placed images in a radius of 5 blocks around the spawn\
Expand Down Expand Up @@ -123,6 +158,28 @@ You can change which roles or players are granted these commands by using a perm
such as [LuckPerms](https://luckperms.net/) or [GroupManager](https://elgarl.github.io/GroupManager/).
Both these plugins have been tested to work with Yamipa, although any similar one should work just fine.

## Player variables
Some permission plugins like LuckPerms allow server operators to assign
[key-value pairs](https://luckperms.net/wiki/Meta-Commands) to entities as if they were permissions.
This is useful for granting different capabilities to different players or groups.

Yamipa looks for the following variables which, if found, override the default configuration value that applies to all
players:

| Variable (key) | Overrides | Description |
|:-----------------------------|:----------------------|:----------------------------------------------------------------------------------|
| `yamipa-allowed-paths` | `allowed-paths` | Regular expression that limits which paths in the images directory are accessible |
| `yamipa-max-image-dimension` | `max-image-dimension` | Maximum width or height of images and image items issued by this player or group |

For example, if you want to limit the image size to 5x5 blocks just for the "test" player, you can run this command:
```sh
# Using LuckPerms
/lp user test meta set yamipa-max-image-dimension 5
# Using GroupManager
/manuaddv test yamipa-max-image-dimension 5
```

## Protecting areas
In large servers, letting your players place and remove images wherever they want might not be the most sensible idea.
For those cases, Yamipa is compatible with other Bukkit plugins that allow creating and managing world areas.
Expand Down
22 changes: 19 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.josemmo.bukkit.plugin</groupId>
<artifactId>YamipaPlugin</artifactId>
<version>1.2.13</version>
<version>1.3.0</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down Expand Up @@ -62,13 +62,29 @@
<scope>provided</scope>
</dependency>

<!-- https://repo.maven.apache.org/maven2/org/bstats/bstats-bukkit/ -->
<!-- https://central.sonatype.com/artifact/org.bstats/bstats-bukkit -->
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.2</version>
</dependency>

<!-- https://central.sonatype.com/artifact/net.luckperms/api -->
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>

<!-- https://jitpack.io/com/github/ElgarL/groupmanager/ -->
<dependency>
<groupId>com.github.ElgarL</groupId>
<artifactId>groupmanager</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>

<!-- https://maven.enginehub.org/artifactory/repo/com/sk89q/worldguard/worldguard-bukkit/ -->
<dependency>
<groupId>com.sk89q.worldguard</groupId>
Expand Down Expand Up @@ -101,7 +117,7 @@
<scope>provided</scope>
</dependency>

<!-- https://repo.maven.apache.org/maven2/org/jetbrains/annotations/ -->
<!-- https://central.sonatype.com/artifact/org.jetbrains/annotations -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand Down
Loading

0 comments on commit 17c59ea

Please sign in to comment.