mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-03 02:09:52 +08:00
Fix /time permissions to allow players to check time with just essentials.time. Remvoe timeSetAllPermission message as it is no longer used.
This commit is contained in:
parent
27a297a18d
commit
7809615896
@ -86,7 +86,14 @@ public class Commandtime extends EssentialsCommand {
|
|||||||
/**
|
/**
|
||||||
* Used to set the time and inform of the change
|
* Used to set the time and inform of the change
|
||||||
*/
|
*/
|
||||||
private void setWorldsTime(final CommandSource sender, final Collection<World> worlds, final long ticks, final boolean add) {
|
private void setWorldsTime(final CommandSource sender, final Collection<World> worlds, final long ticks, final boolean add) throws Exception {
|
||||||
|
User user = ess.getUser(sender.getPlayer());
|
||||||
|
for (World world : worlds) {
|
||||||
|
if (!canUpdateWorld(user, world)) {
|
||||||
|
throw new Exception(tl("timeSetWorldPermission", user.getWorld().getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update the time
|
// Update the time
|
||||||
for (World world : worlds) {
|
for (World world : worlds) {
|
||||||
long time = world.getTime();
|
long time = world.getTime();
|
||||||
@ -113,14 +120,12 @@ public class Commandtime extends EssentialsCommand {
|
|||||||
*/
|
*/
|
||||||
private Set<World> getWorlds(final Server server, final CommandSource sender, final String selector) throws Exception {
|
private Set<World> getWorlds(final Server server, final CommandSource sender, final String selector) throws Exception {
|
||||||
final Set<World> worlds = new TreeSet<>(new WorldNameComparator());
|
final Set<World> worlds = new TreeSet<>(new WorldNameComparator());
|
||||||
User user = ess.getUser(sender.getPlayer());
|
|
||||||
|
|
||||||
// If there is no selector we want the world the user is currently in. Or all worlds if it isn't a user.
|
// If there is no selector we want the world the user is currently in. Or all worlds if it isn't a user.
|
||||||
if (selector == null) {
|
if (selector == null) {
|
||||||
if (sender.isPlayer()) {
|
if (sender.isPlayer()) {
|
||||||
if (!canUpdateWorld(user, user.getWorld())) {
|
|
||||||
throw new Exception(tl("timeSetWorldPermission", user.getWorld().getName()));
|
final User user = ess.getUser(sender.getPlayer());
|
||||||
}
|
|
||||||
worlds.add(user.getWorld());
|
worlds.add(user.getWorld());
|
||||||
} else {
|
} else {
|
||||||
worlds.addAll(server.getWorlds());
|
worlds.addAll(server.getWorlds());
|
||||||
@ -131,30 +136,11 @@ public class Commandtime extends EssentialsCommand {
|
|||||||
// Try to find the world with name = selector
|
// Try to find the world with name = selector
|
||||||
final World world = server.getWorld(selector);
|
final World world = server.getWorld(selector);
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
if (!canUpdateWorld(user, world)) {
|
|
||||||
throw new Exception(tl("timeSetWorldPermission", world.getName()));
|
|
||||||
}
|
|
||||||
worlds.add(world);
|
worlds.add(world);
|
||||||
}
|
}
|
||||||
// If that fails, Is the argument something like "*" or "all"?
|
// If that fails, Is the argument something like "*" or "all"?
|
||||||
else if (selector.equalsIgnoreCase("*") || selector.equalsIgnoreCase("all")) {
|
else if (selector.equalsIgnoreCase("*") || selector.equalsIgnoreCase("all")) {
|
||||||
// Add all worlds by default if the sender is console or player has the permission.
|
|
||||||
if (canUpdateAll(user)) {
|
|
||||||
worlds.addAll(server.getWorlds());
|
worlds.addAll(server.getWorlds());
|
||||||
} else {
|
|
||||||
// They don't have the _all_ permission, add worlds that they have permission for.
|
|
||||||
for (World world1 : server.getWorlds()) {
|
|
||||||
if (canUpdateWorld(user, world1)) {
|
|
||||||
worlds.add(world1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify the player if they don't have permission for setting time on all worlds.
|
|
||||||
if (worlds.isEmpty()) {
|
|
||||||
throw new Exception(tl("timeSetAllPermission"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// We failed to understand the world target...
|
// We failed to understand the world target...
|
||||||
else {
|
else {
|
||||||
|
@ -437,7 +437,6 @@ timeBeforeHeal=\u00a74Time before next heal\:\u00a7c {0}\u00a76.
|
|||||||
timeBeforeTeleport=\u00a74Time before next teleport\:\u00a7c {0}\u00a76.
|
timeBeforeTeleport=\u00a74Time before next teleport\:\u00a7c {0}\u00a76.
|
||||||
timeFormat=\u00a7c{0}\u00a76 or \u00a7c{1}\u00a76 or \u00a7c{2}\u00a76
|
timeFormat=\u00a7c{0}\u00a76 or \u00a7c{1}\u00a76 or \u00a7c{2}\u00a76
|
||||||
timeSetPermission=\u00a74You are not authorized to set the time.
|
timeSetPermission=\u00a74You are not authorized to set the time.
|
||||||
timeSetAllPermission=\u00a74You are not authorized to set the time in all worlds.
|
|
||||||
timeSetWorldPermission=\u00a74You are not authorized to set the time in world ''{0}''.
|
timeSetWorldPermission=\u00a74You are not authorized to set the time in world ''{0}''.
|
||||||
timeWorldCurrent=\u00a76The current time in\u00a7c {0} \u00a76is \u00a7c{1}\u00a76.
|
timeWorldCurrent=\u00a76The current time in\u00a7c {0} \u00a76is \u00a7c{1}\u00a76.
|
||||||
timeWorldSet=\u00a76The time was set to\u00a7c {0} \u00a76in\: \u00a7c{1}\u00a76.
|
timeWorldSet=\u00a76The time was set to\u00a7c {0} \u00a76in\: \u00a7c{1}\u00a76.
|
||||||
|
Loading…
Reference in New Issue
Block a user