A few small fixes

This commit is contained in:
Luck 2016-08-20 17:49:23 +01:00
parent 471084a9ef
commit bbeed1e4ed
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
36 changed files with 108 additions and 332 deletions

252
README.md
View File

@ -4,6 +4,7 @@ A permissions implementation for Bukkit/Spigot, BungeeCord and Sponge.
## Links
* **Development Builds** - <https://ci.lucko.me/job/LuckPerms>
* **Javadocs** - <https://jd.lucko.me/LuckPerms>
* **Wiki** - <https://github.com/lucko/LuckPerms/wiki>
## Why LuckPerms?
_Features checked on 19th Aug 2016. If you find any inaccuracies, please do let me know. I tried to be as fair as possible, and copy all major features from the respective plugin pages._
@ -37,256 +38,5 @@ _Features checked on 19th Aug 2016. If you find any inaccuracies, please do let
* **Sponge compatible** - permissions, users and groups are synced across all LuckPerms instances (bukkit --> sponge, for example)
* **Support for MySQL, MongoDB, SQLite, H2 & Flatfile (JSON)** - other storage methods coming soon (maybe)
## Setup
All configuration options are in the **config.yml/luckperms.conf** file, which is generated automagically when the plugin first starts.
You can define the settings for per-server permissions, the storage method and credentials within this file.
## Info
### Permission Calculation
#### Permissions are calculated based on a priority system as follows.
* **Non wildcard/regex permissions will be overridden by normal permissions**
Example: if a user has a true permission set for "luckperms.\*", and a false permission set for "luckperms.something", the non-wildcard permission will override the wildcard, and "luckperms.something" will be set to false, despite the wildcard.
* **More specific wildcards override less specific ones**
Example: if a user has "luckperms.\*" set to true, but "luckperms.user.\*" set to false, all of the user permissions will be set to false, despite the more generic wildcard for "luckperms.*".
* **Temporary permissions will override non-temporary permissions.**
Example: if a user has a false permission set for "test.node", and a temporary true permission set for "test.node", the temporary permission will override the permanent one, and the user will be granted the true node.
* **World specific permissions will override generic permissions.**
Example: if a user has a global "fly.use" permission, and then has a negated "fly.use" permission in the "world_nether" world, the world specific permission will override the globally defined one, and the user will be granted the negated node (provided they're in that world, of course.).
* **Server specific permissions will override generic/global permissions.**
Example: if a user has a global "fly.use" permission, and then has a negated "fly.use" permission on the "factions" server, the server specific permission will override the globally defined one, and the user will be granted the negated node (provided they're on that server).
* **Inherited permissions will be overridden by an objects own permissions.**
Example: A user is a member of the default group, which grants "some.thing.perm", but the users own permissions has "some.thing.perm" set to false. The inherited permission will be overridden by the users own permissions, and the user will be granted the negative node.
### Temporary Permissions
Temporary permissions are audited once every 3 seconds, to check if they have expired. This check happens regardless of the sync interval setting. This means that you can safely set temporary permissions to expire after a matter of seconds, and they will be removed on-time.
### Shorthand Permissions
LuckPerms has it's own system (although it's quite similar to PermissionsEx :P) that allows you to set permissions in a shorthand format.
Using the LuckPerms permission nodes as an example, say for instance, you wanted to let a user set and unset permissions for both groups and users.
Without shorthand, you would have to apply 4 nodes.
```
luckperms.user.setpermission
luckperms.user.unsetpermission
luckperms.group.setpermission
luckperms.group.unsetpermission
```
However, with shorthand, you can just apply the following node:
`luckperms.(user|group).(setpermission|unsetpermission)`
You use brackets to define part of a node as a shorthand group, and then use the vertical bar `|` to separate entries.
There are some limitations, firstly, you cannot use shorthand in the first part of the node. (The "luckperms" part in the example above)
Additionally, you cannot combine shorthand and normal text in the same part of the node.
For example, `luckperms.(user|group).(set|unset)permission` would not work.
### Regex
LuckPerms has support for regex when defining permission nodes and server/world names.
Whenever regex is used, it MUST be prefixed with "R=", so LuckPerms knows to treat it as regex, and not as a normal string.
For example, if you wanted to give all members of the default group, the `essentials.fly` permission on all of your hub servers, where the hub server names are hub1, hub2, hub3, etc.
You would use the command `/perms group default set essentials.fly true R=hub\d+`.
You can also use regex in permission nodes.
Once again using LuckPerms permissions as an example, if you wanted a user to be able to create both groups and tracks, you would normally just add the two permission nodes. However with regex, you can just add one. `luckperms\.create.*` Remember to escape any characters, specifically dots, as the entire node will be parsed.
## API
LuckPerms has an extensive API, allowing for easy integration with other projects. To use the Api, you need to obtain an instance of the `LuckPermsApi` interface. This can be done in a number of ways.
```java
// On all platforms (throws IllegalStateException if the API is not loaded)
final LuckPermsApi api = LuckPerms.getApi();
// Or with Optional
Optional<LuckPermsApi> provider = LuckPerms.getApiSafe();
if (provider.isPresent()) {
final LuckPermsApi api = provider.get();
}
// On Bukkit/Spigot
ServicesManager manager = Bukkit.getServicesManager();
if (manager.isProvidedFor(LuckPermsApi.class)) {
final LuckPermsApi api = manager.getRegistration(LuckPermsApi.class).getProvider();
}
// On Sponge
Optional<LuckPermsApi> provider = Sponge.getServiceManager().provide(LuckPermsApi.class);
if (provider.isPresent()) {
final LuckPermsApi api = provider.get();
}
```
If you want to use LuckPerms in your onEnable method, you need to add the following to your plugins `plugin.yml`.
```yml
depend: [LuckPerms]
```
All of the available methods can be seen in the various interfaces in the `luckperms-api` module.
You can add LuckPerms as a Maven dependency by adding the following to your projects `pom.xml`.
````xml
<repositories>
<repository>
<id>luck-repo</id>
<url>https://repo.lucko.me/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>me.lucko.luckperms</groupId>
<artifactId>luckperms-api</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
````
### Events
LuckPerms exposes a full read/write API, as well as an event listening system. Due to the multi-platform nature of the project, an internal Event system is used, as opposed to the systems already in place on each platform. (the Bukkit Event api, for example). This means that simply registering your listener with the platform is not sufficient.
All events are *fired asynchronously*. This means you should not interact with or call any non-thread safe methods from within listeners.
To listen to an event, you need to first make a class that implements `LPListener`. Then within this class, you can define all of your listener methods.
Each listener method must be annotated with `@Subscribe`. For example...
```java
package me.lucko.test;
import com.google.common.eventbus.Subscribe;
import me.lucko.luckperms.api.event.LPListener;
import me.lucko.luckperms.api.event.events.PermissionSetEvent;
public class TestListener implements LPListener {
@Subscribe
public void onPermissionSet(PermissionSetEvent event) {
}
}
```
You also need to register your new Listener with the API.
```java
@Override
public void onEnable() {
LuckPermsApi api;
api.registerListener(new TestListener());
}
```
## Versioning
As of version 2.0, LuckPerms roughly follows the standards set out in Semantic Versioning.
The only difference is that the patch number is not included anywhere within the pom, and is calculated each build, based upon how may commits have been made since the last tag. (A new tag is made every minor version)
This means that API versions do not have a patch number (as no API changes are made in patches). API versions will be x.y, and each individual build of LuckPerms will follow x.y.z.
## Commands
Command usage is printed to the console/chat whenever invalid arguments are provided. Simply typing /perms will list all commands a user has permission to use.
### Aliases
| Bukkit | Bungee |
|------------------|------------------|
| /luckperms | /luckpermsbungee |
| /perms | /bperms |
| /permissions | /bpermissions |
| /lp | /lpb |
| /perm | /bperm |
Arguments: \<required\> [optional]
Users with OP have access to all commands.
Additionally, you can use wildcards to grant users access to a selection of commands.
* **All commands** - luckperms.*
* **All user commands** - luckperms.user.*
* **All group commands** - luckperms.group.*
* **All track commands** - luckperms.track.*
* **All log commands** - luckperms.log.*
### General
* /perms - n/a
* /perms sync - luckperms.sync
* /perms info - luckperms.info
* /perms debug - luckperms.debug
* /perms import \<file\> - luckperms.import
* /perms creategroup \<group\> - luckperms.creategroup
* /perms deletegroup \<group\> - luckperms.deletegroup
* /perms listgroups - luckperms.listgroups
* /perms createtrack \<track\> - luckperms.createtrack
* /perms deletetrack \<track\> - luckperms.deletetrack
* /perms listtracks - luckperms.listtracks
### User
* /perms user \<user\> info - luckperms.user.info
* /perms user \<user\> getuuid - luckperms.user.getuuid
* /perms user \<user\> listnodes - luckperms.user.listnodes
* /perms user \<user\> haspermission \<node\> [server] [world] - luckperms.user.haspermission
* /perms user \<user\> inheritspermission \<node\> [server] [world] - luckperms.user.inheritspermission
* /perms user \<user\> set \<node\> \<true/false\> [server] [world] - luckperms.user.setpermission
* /perms user \<user\> unset \<node\> [server] [world] - luckperms.user.unsetpermission
* /perms user \<user\> addgroup \<group\> [server] [world] - luckperms.user.addgroup
* /perms user \<user\> removegroup \<group\> [server] [world] - luckperms.user.removegroup
* /perms user \<user\> settemp \<node\> \<true/false\> \<duration\> [server] [world] - luckperms.user.settemppermission
* /perms user \<user\> unsettemp \<node\> [server] [world] - luckperms.user.unsettemppermission
* /perms user \<user\> addtempgroup \<group\> \<duration\> [server] [world] - luckperms.user.addtempgroup
* /perms user \<user\> removetempgroup \<group\> [server] [world] - luckperms.user.removetempgroup
* /perms user \<user\> setprimarygroup \<group\> - luckperms.user.setprimarygroup
* /perms user \<user\> showtracks - luckperms.user.showtracks
* /perms user \<user\> promote \<track\> - luckperms.user.promote
* /perms user \<user\> demote \<track\> - luckperms.user.demote
* /perms user \<user\> showpos \<track\> - luckperms.user.showpos
* /perms user \<user\> clear - luckperms.user.clear
### Group
* /perms group \<group\> info - luckperms.group.info
* /perms group \<group\> listnodes - luckperms.group.listnodes
* /perms group \<group\> haspermission \<node\> [server] [world] - luckperms.group.haspermission
* /perms group \<group\> inheritspermission \<node\> [server] [world] - luckperms.group.inheritspermission
* /perms group \<group\> set \<node\> \<true/false\> [server] [world] - luckperms.group.setpermission
* /perms group \<group\> unset \<node\> [server] [world] - luckperms.group.unsetpermission
* /perms group \<group\> setinherit \<group\> [server] [world] - luckperms.group.setinherit
* /perms group \<group\> unsetinherit \<group\> [server] [world] - luckperms.group.unsetinherit
* /perms group \<group\> settemp \<node\> \<true/false\> \<duration\> [server] [world] - settemppermission
* /perms group \<group\> unsettemp \<node\> [server] [world] - luckperms.group.unsettemppermission
* /perms group \<group\> settempinherit \<group\> \<duration\> [server] [world] - luckperms.group.settempinherit
* /perms group \<group\> unsettempinherit \<group\> [server] [world] - luckperms.group.unsettempinherit
* /perms group \<group\> showtracks - luckperms.group.showtracks
* /perms group \<group\> clear - luckperms.group.clear
### Track
* /perms track \<track\> info - luckperms.track.info
* /perms track \<track\> append \<group\> - luckperms.track.append
* /perms track \<track\> insert \<group\> \<position\> - luckperms.track.insert
* /perms track \<track\> remove \<group\> - luckperms.track.remove
* /perms track \<track\> clear - luckperms.track.clear
### Log
* /perms log recent [user] [page] - luckperms.log.recent
* /perms log search \<query\> [page] - luckperms.log.search
* /perms log notify [on|off] - luckperms.log.notify
* /perms log export \<file\> - luckperms.log.export
* /perms log userhistory \<user\> [page] - luckperms.log.userhistory
* /perms log grouphistory \<group\> [page] - luckperms.log.grouphistory
* /perms log trackhistory \<track\> [page] - luckperms.log.trackhistory
## License
See LICENSE.md.

View File

@ -34,9 +34,8 @@ import java.util.stream.Collectors;
* @param <T> the command sender type
*/
public abstract class SenderFactory<T> implements Runnable {
// Ensures messages are sent in order, etc.
private final List<Runnable> tasks = new ArrayList<>();
private final Map<T, List<String>> messages = new HashMap<>();
//private final List<Map.Entry<T, String>> messages = new ArrayList<>();
private final SenderFactory<T> factory = this;
protected abstract String getName(T t);
@ -63,8 +62,12 @@ public abstract class SenderFactory<T> implements Runnable {
public void sendMessage(String s) {
final T t = tRef.get();
if (t != null) {
synchronized (tasks) {
tasks.add(() -> factory.sendMessage(t, s));
synchronized (messages) {
if (!messages.containsKey(t)) {
messages.put(t, new ArrayList<>());
}
messages.get(t).add(s);
}
}
}
@ -80,10 +83,10 @@ public abstract class SenderFactory<T> implements Runnable {
@Override
public final void run() {
synchronized (tasks) {
if (!tasks.isEmpty()) {
tasks.forEach(Runnable::run);
tasks.clear();
synchronized (messages) {
if (!messages.isEmpty()) {
messages.entrySet().forEach(e -> e.getValue().forEach(s -> factory.sendMessage(e.getKey(), s)));
messages.clear();
}
}
}

View File

@ -62,7 +62,7 @@ public class CreateGroup extends SingleMainCommand {
}
Message.CREATE_SUCCESS.send(sender, groupName);
LogEntry.build().actor(sender).actedName(groupName).type('G').action("create").build().submit(plugin);
LogEntry.build().actor(sender).actedName(groupName).type('G').action("create").build().submit(plugin, sender);
plugin.runUpdateTask();
return CommandResult.SUCCESS;
}

View File

@ -78,7 +78,7 @@ public class DeleteGroup extends SingleMainCommand {
}
Message.DELETE_SUCCESS.send(sender, groupName);
LogEntry.build().actor(sender).actedName(groupName).type('G').action("delete").build().submit(plugin);
LogEntry.build().actor(sender).actedName(groupName).type('G').action("delete").build().submit(plugin, sender);
plugin.runUpdateTask();
return CommandResult.SUCCESS;
}

View File

@ -44,7 +44,7 @@ public class GroupClear extends SubCommand<Group> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
group.clearNodes();
Message.CLEAR_SUCCESS.send(sender, group.getName());
LogEntry.build().actor(sender).acted(group).action("clear").build().submit(plugin);
LogEntry.build().actor(sender).acted(group).action("clear").build().submit(plugin, sender);
save(group, sender, plugin);
return CommandResult.SUCCESS;
}

View File

@ -76,14 +76,14 @@ public class GroupSetInherit extends SubCommand<Group> {
Message.GROUP_SETINHERIT_SERVER_SUCCESS.send(sender, group.getName(), group1.getName(), server);
LogEntry.build().actor(sender).acted(group)
.action("setinherit " + group1.getName() + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(2).toLowerCase();
group.setInheritGroup(group1, server, world);
Message.GROUP_SETINHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), group1.getName(), server, world);
LogEntry.build().actor(sender).acted(group)
.action("setinherit " + group1.getName() + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -91,7 +91,7 @@ public class GroupSetInherit extends SubCommand<Group> {
Message.GROUP_SETINHERIT_SUCCESS.send(sender, group.getName(), group1.getName());
LogEntry.build().actor(sender).acted(group)
.action("setinherit " + group1.getName())
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(group, sender, plugin);

View File

@ -78,14 +78,14 @@ public class GroupSetPermission extends SubCommand<Group> {
Message.SETPERMISSION_SERVER_SUCCESS.send(sender, node, bool, group.getName(), server);
LogEntry.build().actor(sender).acted(group)
.action("set " + node + " " + b + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(3).toLowerCase();
group.setPermission(node, b, server, world);
Message.SETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, bool, group.getName(), server, world);
LogEntry.build().actor(sender).acted(group)
.action("set " + node + " " + b + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -93,7 +93,7 @@ public class GroupSetPermission extends SubCommand<Group> {
Message.SETPERMISSION_SUCCESS.send(sender, node, bool, group.getName());
LogEntry.build().actor(sender).acted(group)
.action("set " + node + " " + b)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(group, sender, plugin);

View File

@ -95,7 +95,7 @@ public class GroupSetTempInherit extends SubCommand<Group> {
DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(group)
.action("settempinherit " + group1.getName() + " " + duration + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(3).toLowerCase();
group.setInheritGroup(group1, server, world, duration);
@ -103,7 +103,7 @@ public class GroupSetTempInherit extends SubCommand<Group> {
world, DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(group)
.action("settempinherit " + group1.getName() + " " + duration + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -111,7 +111,7 @@ public class GroupSetTempInherit extends SubCommand<Group> {
Message.GROUP_SET_TEMP_INHERIT_SUCCESS.send(sender, group.getName(), group1.getName(), DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(group)
.action("settempinherit " + group1.getName() + " " + duration)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(group, sender, plugin);

View File

@ -98,7 +98,7 @@ public class GroupSetTempPermission extends SubCommand<Group> {
DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(group)
.action("settemp " + node + " " + b + " " + duration + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(4).toLowerCase();
group.setPermission(node, b, server, world, duration);
@ -106,7 +106,7 @@ public class GroupSetTempPermission extends SubCommand<Group> {
world, DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(group)
.action("settemp " + node + " " + b + " " + duration + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -114,7 +114,7 @@ public class GroupSetTempPermission extends SubCommand<Group> {
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, bool, group.getName(), DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(group)
.action("settemp " + node + " " + b + " " + duration)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(group, sender, plugin);

View File

@ -70,14 +70,14 @@ public class GroupUnSetPermission extends SubCommand<Group> {
Message.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, group.getName(), server);
LogEntry.build().actor(sender).acted(group)
.action("unset " + node + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(2).toLowerCase();
group.unsetPermission(node, server, world);
Message.UNSETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, group.getName(), server, world);
LogEntry.build().actor(sender).acted(group)
.action("unset " + node + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -85,7 +85,7 @@ public class GroupUnSetPermission extends SubCommand<Group> {
Message.UNSETPERMISSION_SUCCESS.send(sender, node, group.getName());
LogEntry.build().actor(sender).acted(group)
.action("unset " + node)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(group, sender, plugin);

View File

@ -65,14 +65,14 @@ public class GroupUnsetInherit extends SubCommand<Group> {
Message.GROUP_UNSETINHERIT_SERVER_SUCCESS.send(sender, group.getName(), groupName, server);
LogEntry.build().actor(sender).acted(group)
.action("unsetinherit " + groupName + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(2).toLowerCase();
group.unsetPermission("group." + groupName, server, world);
Message.GROUP_UNSETINHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), groupName, server, world);
LogEntry.build().actor(sender).acted(group)
.action("unsetinherit " + groupName + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -80,7 +80,7 @@ public class GroupUnsetInherit extends SubCommand<Group> {
Message.GROUP_UNSETINHERIT_SUCCESS.send(sender, group.getName(), groupName);
LogEntry.build().actor(sender).acted(group)
.action("unsetinherit " + groupName)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(group, sender, plugin);

View File

@ -65,14 +65,14 @@ public class GroupUnsetTempInherit extends SubCommand<Group> {
Message.GROUP_UNSET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, group.getName(), groupName, server);
LogEntry.build().actor(sender).acted(group)
.action("unsettempinherit " + groupName + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(2).toLowerCase();
group.unsetPermission("group." + groupName, server, world, true);
Message.GROUP_UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), groupName, server, world);
LogEntry.build().actor(sender).acted(group)
.action("unsettempinherit " + groupName + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -80,7 +80,7 @@ public class GroupUnsetTempInherit extends SubCommand<Group> {
Message.GROUP_UNSET_TEMP_INHERIT_SUCCESS.send(sender, group.getName(), groupName);
LogEntry.build().actor(sender).acted(group)
.action("unsettempinherit " + groupName)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(group, sender, plugin);

View File

@ -71,14 +71,14 @@ public class GroupUnsetTempPermission extends SubCommand<Group> {
Message.UNSET_TEMP_PERMISSION_SERVER_SUCCESS.send(sender, node, group.getName(), server);
LogEntry.build().actor(sender).acted(group)
.action("unsettemp " + node + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(2).toLowerCase();
group.unsetPermission(node, server, world);
Message.UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, group.getName(), server, world);
LogEntry.build().actor(sender).acted(group)
.action("unsettemp " + node + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -86,7 +86,7 @@ public class GroupUnsetTempPermission extends SubCommand<Group> {
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, group.getName());
LogEntry.build().actor(sender).acted(group)
.action("unsettemp " + node)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(group, sender, plugin);

View File

@ -46,7 +46,7 @@ public class LogGroupHistory extends SubCommand<Log> {
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) {
String group = args.get(0);
String group = args.get(0).toLowerCase();
int page = -999;
if (args.size() == 2) {

View File

@ -46,7 +46,7 @@ public class LogTrackHistory extends SubCommand<Log> {
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) {
String track = args.get(0);
String track = args.get(0).toLowerCase();
int page = -999;
if (args.size() == 2) {

View File

@ -62,7 +62,7 @@ public class CreateTrack extends SingleMainCommand {
}
Message.CREATE_SUCCESS.send(sender, trackName);
LogEntry.build().actor(sender).actedName(trackName).type('T').action("create").build().submit(plugin);
LogEntry.build().actor(sender).actedName(trackName).type('T').action("create").build().submit(plugin, sender);
plugin.runUpdateTask();
return CommandResult.SUCCESS;
}

View File

@ -72,7 +72,7 @@ public class DeleteTrack extends SingleMainCommand {
}
Message.DELETE_SUCCESS.send(sender, trackName);
LogEntry.build().actor(sender).actedName(trackName).type('T').action("delete").build().submit(plugin);
LogEntry.build().actor(sender).actedName(trackName).type('T').action("delete").build().submit(plugin, sender);
plugin.runUpdateTask();
return CommandResult.SUCCESS;
}

View File

@ -63,10 +63,12 @@ public class TrackAppend extends SubCommand<Track> {
try {
track.appendGroup(group);
Message.TRACK_APPEND_SUCCESS.send(sender, group.getName(), track.getName());
if (track.getGroups().size() > 1) {
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), group.getName()));
}
LogEntry.build().actor(sender).acted(track)
.action("append " + group.getName())
.build().submit(plugin);
.build().submit(plugin, sender);
save(track, sender, plugin);
return CommandResult.SUCCESS;
} catch (ObjectAlreadyHasException e) {

View File

@ -44,7 +44,7 @@ public class TrackClear extends SubCommand<Track> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
track.clearGroups();
Message.TRACK_CLEAR.send(sender, track.getName());
LogEntry.build().actor(sender).acted(track).action("clear").build().submit(plugin);
LogEntry.build().actor(sender).acted(track).action("clear").build().submit(plugin, sender);
save(track, sender, plugin);
return CommandResult.SUCCESS;
}

View File

@ -71,10 +71,12 @@ public class TrackInsert extends SubCommand<Track> {
try {
track.insertGroup(group, pos - 1);
Message.TRACK_INSERT_SUCCESS.send(sender, group.getName(), track.getName(), pos);
if (track.getGroups().size() > 1) {
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), group.getName()));
}
LogEntry.build().actor(sender).acted(track)
.action("insert " + group.getName() + " " + pos)
.build().submit(plugin);
.build().submit(plugin, sender);
save(track, sender, plugin);
return CommandResult.SUCCESS;
} catch (ObjectAlreadyHasException e) {

View File

@ -51,10 +51,12 @@ public class TrackRemove extends SubCommand<Track> {
try {
track.removeGroup(groupName);
Message.TRACK_REMOVE_SUCCESS.send(sender, groupName, track.getName());
if (track.getGroups().size() > 1) {
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups()));
}
LogEntry.build().actor(sender).acted(track)
.action("remove " + groupName)
.build().submit(plugin);
.build().submit(plugin, sender);
save(track, sender, plugin);
return CommandResult.SUCCESS;
} catch (ObjectLacksException e) {

View File

@ -76,14 +76,14 @@ public class UserAddGroup extends SubCommand<User> {
Message.USER_ADDGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server);
LogEntry.build().actor(sender).acted(user)
.action("addgroup " + group.getName() + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(2).toLowerCase();
user.addGroup(group, server, world);
Message.USER_ADDGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server, world);
LogEntry.build().actor(sender).acted(user)
.action("addgroup " + group.getName() + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -91,7 +91,7 @@ public class UserAddGroup extends SubCommand<User> {
Message.USER_ADDGROUP_SUCCESS.send(sender, user.getName(), groupName);
LogEntry.build().actor(sender).acted(user)
.action("addgroup " + group.getName())
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(user, sender, plugin);

View File

@ -96,7 +96,7 @@ public class UserAddTempGroup extends SubCommand<User> {
DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(user)
.action("addtempgroup " + group.getName() + " " + duration + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(3).toLowerCase();
user.addGroup(group, server, world, duration);
@ -104,7 +104,7 @@ public class UserAddTempGroup extends SubCommand<User> {
world, DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(user)
.action("addtempgroup " + group.getName() + " " + duration + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -112,7 +112,7 @@ public class UserAddTempGroup extends SubCommand<User> {
Message.USER_ADDTEMPGROUP_SUCCESS.send(sender, user.getName(), groupName, DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(user)
.action("addtempgroup " + group.getName() + " " + duration)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(user, sender, plugin);

View File

@ -45,7 +45,7 @@ public class UserClear extends SubCommand<User> {
user.clearNodes();
plugin.getUserManager().giveDefaults(user);
Message.CLEAR_SUCCESS.send(sender, user.getName());
LogEntry.build().actor(sender).acted(user).action("clear").build().submit(plugin);
LogEntry.build().actor(sender).acted(user).action("clear").build().submit(plugin, sender);
save(user, sender, plugin);
return CommandResult.SUCCESS;

View File

@ -108,7 +108,7 @@ public class UserDemote extends SubCommand<User> {
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), previousGroup.getName(), old, true));
LogEntry.build().actor(sender).acted(user)
.action("demote " + track.getName() + "(from " + old + " to " + previousGroup.getName() + ")")
.build().submit(plugin);
.build().submit(plugin, sender);
save(user, sender, plugin);
plugin.getApiProvider().fireEventAsync(new UserDemoteEvent(new TrackLink(track), new UserLink(user), old, previousGroup.getName()));
return CommandResult.SUCCESS;

View File

@ -108,7 +108,7 @@ public class UserPromote extends SubCommand<User> {
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), old, nextGroup.getName(), false));
LogEntry.build().actor(sender).acted(user)
.action("promote " + track.getName() + "(from " + old + " to " + nextGroup.getName() + ")")
.build().submit(plugin);
.build().submit(plugin, sender);
save(user, sender, plugin);
plugin.getApiProvider().fireEventAsync(new UserPromoteEvent(new TrackLink(track), new UserLink(user), old, nextGroup.getName()));
return CommandResult.SUCCESS;

View File

@ -70,14 +70,14 @@ public class UserRemoveGroup extends SubCommand<User> {
Message.USER_REMOVEGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server);
LogEntry.build().actor(sender).acted(user)
.action("removegroup " + groupName + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(2).toLowerCase();
user.unsetPermission("group." + groupName, server, world);
Message.USER_REMOVEGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server, world);
LogEntry.build().actor(sender).acted(user)
.action("removegroup " + groupName + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -85,7 +85,7 @@ public class UserRemoveGroup extends SubCommand<User> {
Message.USER_REMOVEGROUP_SUCCESS.send(sender, user.getName(), groupName);
LogEntry.build().actor(sender).acted(user)
.action("removegroup " + groupName)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(user, sender, plugin);

View File

@ -65,14 +65,14 @@ public class UserRemoveTempGroup extends SubCommand<User> {
Message.USER_REMOVETEMPGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server);
LogEntry.build().actor(sender).acted(user)
.action("removetempgroup " + groupName + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(2).toLowerCase();
user.unsetPermission("group." + groupName, server, world, true);
Message.USER_REMOVETEMPGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server, world);
LogEntry.build().actor(sender).acted(user)
.action("removetempgroup " + groupName + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -80,7 +80,7 @@ public class UserRemoveTempGroup extends SubCommand<User> {
Message.USER_REMOVETEMPGROUP_SUCCESS.send(sender, user.getName(), groupName);
LogEntry.build().actor(sender).acted(user)
.action("removetempgroup " + groupName)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(user, sender, plugin);

View File

@ -79,14 +79,14 @@ public class UserSetPermission extends SubCommand<User> {
Message.SETPERMISSION_SERVER_SUCCESS.send(sender, node, bool, user.getName(), server);
LogEntry.build().actor(sender).acted(user)
.action("set " + node + " " + b + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(3).toLowerCase();
user.setPermission(node, b, server, world);
Message.SETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, bool, user.getName(), server, world);
LogEntry.build().actor(sender).acted(user)
.action("set " + node + " " + b + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -94,7 +94,7 @@ public class UserSetPermission extends SubCommand<User> {
Message.SETPERMISSION_SUCCESS.send(sender, node, bool, user.getName());
LogEntry.build().actor(sender).acted(user)
.action("set " + node + " " + b)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(user, sender, plugin);

View File

@ -63,7 +63,7 @@ public class UserSetPrimaryGroup extends SubCommand<User> {
Message.USER_PRIMARYGROUP_SUCCESS.send(sender, user.getName(), group.getName());
LogEntry.build().actor(sender).acted(user)
.action("setprimarygroup " + group.getName())
.build().submit(plugin);
.build().submit(plugin, sender);
save(user, sender, plugin);
return CommandResult.SUCCESS;

View File

@ -97,14 +97,14 @@ public class UserSetTempPermission extends SubCommand<User> {
Message.SETPERMISSION_TEMP_SERVER_SUCCESS.send(sender, node, bool, user.getName(), server, DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(user)
.action("settemp " + node + " " + b + " " + duration + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(4).toLowerCase();
user.setPermission(node, b, server, world, duration);
Message.SETPERMISSION_TEMP_SERVER_WORLD_SUCCESS.send(sender, node, bool, user.getName(), server, world, DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(user)
.action("settemp " + node + " " + b + " " + duration + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -112,7 +112,7 @@ public class UserSetTempPermission extends SubCommand<User> {
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, bool, user.getName(), DateUtil.formatDateDiff(duration));
LogEntry.build().actor(sender).acted(user)
.action("settemp " + node + " " + b + " " + duration)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(user, sender, plugin);

View File

@ -70,14 +70,14 @@ public class UserUnSetPermission extends SubCommand<User> {
Message.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, user.getName(), server);
LogEntry.build().actor(sender).acted(user)
.action("unset " + node + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(2).toLowerCase();
user.unsetPermission(node, server, world);
Message.UNSETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, user.getName(), server, world);
LogEntry.build().actor(sender).acted(user)
.action("unset " + node + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -85,7 +85,7 @@ public class UserUnSetPermission extends SubCommand<User> {
Message.UNSETPERMISSION_SUCCESS.send(sender, node, user.getName());
LogEntry.build().actor(sender).acted(user)
.action("unset " + node)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(user, sender, plugin);

View File

@ -71,14 +71,14 @@ public class UserUnsetTempPermission extends SubCommand<User> {
Message.UNSET_TEMP_PERMISSION_SERVER_SUCCESS.send(sender, node, user.getName(), server);
LogEntry.build().actor(sender).acted(user)
.action("unsettemp " + node + " " + server)
.build().submit(plugin);
.build().submit(plugin, sender);
} else {
final String world = args.get(2).toLowerCase();
user.unsetPermission(node, server, world, true);
Message.UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, user.getName(), server, world);
LogEntry.build().actor(sender).acted(user)
.action("unsettemp " + node + " " + server + " " + world)
.build().submit(plugin);
.build().submit(plugin, sender);
}
} else {
@ -86,7 +86,7 @@ public class UserUnsetTempPermission extends SubCommand<User> {
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, user.getName());
LogEntry.build().actor(sender).acted(user)
.action("unsettemp " + node)
.build().submit(plugin);
.build().submit(plugin, sender);
}
save(user, sender, plugin);

View File

@ -332,9 +332,8 @@ public abstract class PermissionHolder {
builder.append("/");
} else {
if (world != null) {
builder.append("global-").append(world);
builder.append("global-").append(world).append("/");
}
builder.append("/");
}
builder.append(node);
@ -346,7 +345,7 @@ public abstract class PermissionHolder {
final String finalNode = builder.toString();
if (hasPermission(node, value)) {
if (hasPermission(finalNode, value)) {
throw new ObjectAlreadyHasException();
}
@ -431,9 +430,8 @@ public abstract class PermissionHolder {
builder.append("/");
} else {
if (world != null) {
builder.append("global-").append(world);
builder.append("global-").append(world).append("/");
}
builder.append("/");
}
builder.append(node);

View File

@ -44,7 +44,7 @@ public class LogEntry extends me.lucko.luckperms.api.LogEntry {
super();
}
public void submit(LuckPermsPlugin plugin) {
public void submit(LuckPermsPlugin plugin, Sender sender) {
plugin.getDatastore().logAction(this);
LogNotifyEvent event = new LogNotifyEvent(this);
@ -60,6 +60,7 @@ public class LogEntry extends me.lucko.luckperms.api.LogEntry {
senders.stream()
.filter(s -> !plugin.getIgnoringLogs().contains(s.getUuid()))
.filter(s -> !s.getUuid().equals(sender.getUuid()))
.forEach(s -> Message.LOG.send(s, msg));
}

18
pom.xml
View File

@ -15,7 +15,25 @@
<module>sponge</module>
</modules>
<name>LuckPerms</name>
<description>An advanced permissions implementation for Bukkit/Spigot, BungeeCord and Sponge.</description>
<url>https://github.com/lucko/LuckPerms</url>
<licenses>
<license>
<name>MIT</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>
<scm>
<connection>scm:git:https://github.com/lucko/LuckPerms.git</connection>
<developerConnection>scm:git:git@github.com:lucko/LuckPerms.git</developerConnection>
<url>https://github.com/lucko/LuckPerms</url>
</scm>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<release.version>2.5</release.version>