Skip to content

Commit 17c59ea

Browse files
authored
Merge pull request #112 from josemmo/develop
v1.3.0
2 parents 347ab60 + b0f6330 commit 17c59ea

34 files changed

+1445
-803
lines changed

.github/workflows/tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,19 @@ jobs:
109109
echo "Plugin did not enabled verbose mode"
110110
exit 1
111111
fi
112-
if ! grep -Fq '[YamipaPlugin] Found 5 file(s) in images directory' server.log; then
112+
if ! grep -Fq '[YamipaPlugin] [ImageStorage] Found 5 file(s) in images directory' server.log; then
113113
echo "Plugin did not read image directory"
114114
exit 1
115115
fi
116-
if ! grep -Fq '[YamipaPlugin] Fixed command permissions' server.log; then
116+
if ! grep -Fq '[YamipaPlugin] [ImageCommandBridge] Fixed command permissions' server.log; then
117117
echo "Plugin did not fixed command permissions"
118118
exit 1
119119
fi
120-
if ! grep -Fq '[YamipaPlugin] Created FakeImage' server.log; then
120+
if ! grep -Fq '[YamipaPlugin] [FakeImage] Created FakeImage' server.log; then
121121
echo "Plugin did not place the fake image"
122122
exit 1
123123
fi
124-
if ! grep -Fq '[YamipaPlugin] Invalidated FakeImage' server.log; then
124+
if ! grep -Fq '[YamipaPlugin] [FakeImage] Invalidated FakeImage' server.log; then
125125
echo "Plugin did not remove the fake image"
126126
exit 1
127127
fi

README.md

+69-12
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,50 @@ Yamipa is ready-to-go right out of the box. By default, it creates the following
4545
- `images.dat`: A file holding the list and properties (e.g. coordinates) of all placed images in your server. You
4646
shouldn't modify its contents.
4747

48-
You can change the default path of these files by creating a `config.yml` file in the plugin configuration directory:
48+
You can change the path of these files by creating a `config.yml` file in the plugin configuration directory.
49+
Here are the default configuration values if you don't specify them:
4950
```yaml
50-
verbose: false # Set to "true" to enable more verbose logging
51-
animate-images: true # Set to "false" to disable GIF support
52-
images-path: images # Path to images directory
53-
cache-path: cache # Path to cache directory
54-
data-path: images.dat # Path to placed images database file
51+
verbose: false # Set to "true" to enable more verbose logging
52+
animate-images: true # Set to "false" to disable GIF support
53+
images-path: images # Path to images directory
54+
cache-path: cache # Path to cache directory
55+
data-path: images.dat # Path to placed images database file
56+
allowed-paths: null # Set to a RegExp to limit accessible images to players
57+
max-image-dimension: 30 # Maximum width or height in blocks allowed in images
5558
```
5659
60+
For more information on how to set a different `allowed-paths` or `max-image-dimension` value per player, see the
61+
[Player variables](#player-variables) section.
62+
63+
### Allowed paths
64+
The variable `allowed-paths` is a regular expression that determines whether a player is allowed to see or download
65+
an image file. If the desired path relative to the images directory matches this expression, then the player is allowed
66+
to continue.
67+
68+
If `allowed-paths` is an empty string ("") or null, then the player can read any image file or download to any path
69+
inside the images directory.
70+
71+
This regular expression must follow
72+
[the syntax used by Java](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html). You can test your
73+
expression beforehand using an online tool like [regex101](https://regex101.com/).
74+
In addition, you can make use of the following special tokens:
75+
76+
- `#player#`: Player name
77+
- `#uuid#`: Player UUID (with hyphens)
78+
79+
For example, if you want every player in your server to have their own subdirectory for storing files that only they
80+
can access, plus a shared public directory, you can use the following `allowed-paths` value:
81+
```regexp
82+
^(private/#player#|public)/
83+
```
84+
85+
That way, the player "john" can see the image file at "private/john/something.jpg", but "jane" cannot.
86+
87+
> **IMPORTANT!**\
88+
> Note that these restrictions **also apply to other entities** like NPCs, command blocks or the server console.
89+
> However, special tokens will always match in non-player contexts (e.g., "#player#" will be interpreted as ".+").
90+
91+
### bStats
5792
This library uses bStats to anonymously report the number of installs. If you don't like this, feel free to
5893
disable it at any time by adding `enabled: false` to the
5994
[bStats configuration file](https://bstats.org/getting-started#:~:text=Disabling%20bStats) (it's ok, no hard feelings).
@@ -75,17 +110,17 @@ This plugin adds the following commands:
75110
- Show help\
76111
`/image`
77112
- Download an image from a URL and save it with another name\
78-
`/image download "https://www.example.com/a/b/c/1234.jpg" imagename.jpg`
113+
`/image download "https://www.example.com/a/b/c/1234.jpg" "imagename.jpg"`
79114
- Give 10 image items to "TestPlayer" for the "test.jpg" image (3x5 blocks)\
80-
`/image give TestPlayer test.jpg 10 3 5`
115+
`/image give TestPlayer "test.jpg" 10 3 5`
81116
- Give 10 image items to "TestPlayer" that will not drop an image item when removed\
82-
`/image give TestPlayer test.jpg 10 3 5 -DROP`
117+
`/image give TestPlayer "test.jpg" 10 3 5 -DROP`
83118
- Start the dialog to place an image with a width of 3 blocks and auto height\
84-
`/image place imagename.jpg 3`
119+
`/image place "imagename.jpg" 3`
85120
- Start the dialog to place a 3-blocks wide and 2-blocks high image\
86-
`/image place imagename.jpg 3 2`
121+
`/image place "imagename.jpg" 3 2`
87122
- Start the dialog to place an image that glows in the dark\
88-
`/image place imagename.jpg 3 2 +GLOW`
123+
`/image place "imagename.jpg" 3 2 +GLOW`
89124
- Start the dialog to remove a placed image while keeping the original file\
90125
`/image remove`
91126
- Remove all placed images in a radius of 5 blocks around the spawn\
@@ -123,6 +158,28 @@ You can change which roles or players are granted these commands by using a perm
123158
such as [LuckPerms](https://luckperms.net/) or [GroupManager](https://elgarl.github.io/GroupManager/).
124159
Both these plugins have been tested to work with Yamipa, although any similar one should work just fine.
125160

161+
## Player variables
162+
Some permission plugins like LuckPerms allow server operators to assign
163+
[key-value pairs](https://luckperms.net/wiki/Meta-Commands) to entities as if they were permissions.
164+
This is useful for granting different capabilities to different players or groups.
165+
166+
Yamipa looks for the following variables which, if found, override the default configuration value that applies to all
167+
players:
168+
169+
| Variable (key) | Overrides | Description |
170+
|:-----------------------------|:----------------------|:----------------------------------------------------------------------------------|
171+
| `yamipa-allowed-paths` | `allowed-paths` | Regular expression that limits which paths in the images directory are accessible |
172+
| `yamipa-max-image-dimension` | `max-image-dimension` | Maximum width or height of images and image items issued by this player or group |
173+
174+
For example, if you want to limit the image size to 5x5 blocks just for the "test" player, you can run this command:
175+
```sh
176+
# Using LuckPerms
177+
/lp user test meta set yamipa-max-image-dimension 5
178+
179+
# Using GroupManager
180+
/manuaddv test yamipa-max-image-dimension 5
181+
```
182+
126183
## Protecting areas
127184
In large servers, letting your players place and remove images wherever they want might not be the most sensible idea.
128185
For those cases, Yamipa is compatible with other Bukkit plugins that allow creating and managing world areas.

pom.xml

+19-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.josemmo.bukkit.plugin</groupId>
88
<artifactId>YamipaPlugin</artifactId>
9-
<version>1.2.13</version>
9+
<version>1.3.0</version>
1010

1111
<properties>
1212
<maven.compiler.source>8</maven.compiler.source>
@@ -62,13 +62,29 @@
6262
<scope>provided</scope>
6363
</dependency>
6464

65-
<!-- https://repo.maven.apache.org/maven2/org/bstats/bstats-bukkit/ -->
65+
<!-- https://central.sonatype.com/artifact/org.bstats/bstats-bukkit -->
6666
<dependency>
6767
<groupId>org.bstats</groupId>
6868
<artifactId>bstats-bukkit</artifactId>
6969
<version>3.0.2</version>
7070
</dependency>
7171

72+
<!-- https://central.sonatype.com/artifact/net.luckperms/api -->
73+
<dependency>
74+
<groupId>net.luckperms</groupId>
75+
<artifactId>api</artifactId>
76+
<version>5.4</version>
77+
<scope>provided</scope>
78+
</dependency>
79+
80+
<!-- https://jitpack.io/com/github/ElgarL/groupmanager/ -->
81+
<dependency>
82+
<groupId>com.github.ElgarL</groupId>
83+
<artifactId>groupmanager</artifactId>
84+
<version>3.2</version>
85+
<scope>provided</scope>
86+
</dependency>
87+
7288
<!-- https://maven.enginehub.org/artifactory/repo/com/sk89q/worldguard/worldguard-bukkit/ -->
7389
<dependency>
7490
<groupId>com.sk89q.worldguard</groupId>
@@ -101,7 +117,7 @@
101117
<scope>provided</scope>
102118
</dependency>
103119

104-
<!-- https://repo.maven.apache.org/maven2/org/jetbrains/annotations/ -->
120+
<!-- https://central.sonatype.com/artifact/org.jetbrains/annotations -->
105121
<dependency>
106122
<groupId>org.jetbrains</groupId>
107123
<artifactId>annotations</artifactId>

0 commit comments

Comments
 (0)