mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
Change update messages to account for more than just redis messaging
This commit is contained in:
parent
5039a05055
commit
424af27a47
@ -64,7 +64,7 @@ import me.lucko.luckperms.common.managers.UserManager;
|
||||
import me.lucko.luckperms.common.managers.impl.GenericGroupManager;
|
||||
import me.lucko.luckperms.common.managers.impl.GenericTrackManager;
|
||||
import me.lucko.luckperms.common.managers.impl.GenericUserManager;
|
||||
import me.lucko.luckperms.common.messaging.AbstractMessagingService;
|
||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||
import me.lucko.luckperms.common.messaging.RedisMessaging;
|
||||
import me.lucko.luckperms.common.storage.Storage;
|
||||
import me.lucko.luckperms.common.storage.StorageFactory;
|
||||
@ -117,7 +117,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
private GroupManager groupManager;
|
||||
private TrackManager trackManager;
|
||||
private Storage storage;
|
||||
private AbstractMessagingService messagingService = null;
|
||||
private InternalMessagingService messagingService = null;
|
||||
private UuidCache uuidCache;
|
||||
private BukkitListener listener;
|
||||
private ApiProvider apiProvider;
|
||||
|
@ -55,7 +55,7 @@ import me.lucko.luckperms.common.managers.UserManager;
|
||||
import me.lucko.luckperms.common.managers.impl.GenericGroupManager;
|
||||
import me.lucko.luckperms.common.managers.impl.GenericTrackManager;
|
||||
import me.lucko.luckperms.common.managers.impl.GenericUserManager;
|
||||
import me.lucko.luckperms.common.messaging.AbstractMessagingService;
|
||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||
import me.lucko.luckperms.common.messaging.RedisMessaging;
|
||||
import me.lucko.luckperms.common.storage.Storage;
|
||||
import me.lucko.luckperms.common.storage.StorageFactory;
|
||||
@ -93,7 +93,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
||||
private GroupManager groupManager;
|
||||
private TrackManager trackManager;
|
||||
private Storage storage;
|
||||
private AbstractMessagingService messagingService = null;
|
||||
private InternalMessagingService messagingService = null;
|
||||
private UuidCache uuidCache;
|
||||
private ApiProvider apiProvider;
|
||||
private Logger log;
|
||||
|
@ -42,7 +42,7 @@ import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.managers.GroupManager;
|
||||
import me.lucko.luckperms.common.managers.TrackManager;
|
||||
import me.lucko.luckperms.common.managers.UserManager;
|
||||
import me.lucko.luckperms.common.messaging.AbstractMessagingService;
|
||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||
import me.lucko.luckperms.common.storage.Storage;
|
||||
import me.lucko.luckperms.common.utils.BufferedRequest;
|
||||
import me.lucko.luckperms.common.utils.PermissionCache;
|
||||
@ -103,7 +103,7 @@ public interface LuckPermsPlugin {
|
||||
*
|
||||
* @return the redis messaging service
|
||||
*/
|
||||
AbstractMessagingService getMessagingService();
|
||||
InternalMessagingService getMessagingService();
|
||||
|
||||
/**
|
||||
* Gets a wrapped logger instance for the platform.
|
||||
|
@ -67,6 +67,7 @@ public class InfoCommand extends SingleCommand {
|
||||
plugin.getStorage().getName(),
|
||||
c.get(ConfigKeys.SERVER),
|
||||
c.get(ConfigKeys.SYNC_TIME),
|
||||
plugin.getMessagingService() == null ? "None" : plugin.getMessagingService().getName(),
|
||||
plugin.getPlayerCount(),
|
||||
plugin.getUserManager().getAll().size(),
|
||||
plugin.getGroupManager().getAll().size(),
|
||||
@ -77,7 +78,6 @@ public class InfoCommand extends SingleCommand {
|
||||
plugin.getPreProcessContexts(false).size(),
|
||||
plugin.getContextManager().getCalculatorsSize(),
|
||||
formatBoolean(c.get(ConfigKeys.ONLINE_MODE)),
|
||||
formatBoolean(c.get(ConfigKeys.REDIS_ENABLED)),
|
||||
formatBoolean(c.get(ConfigKeys.INCLUDING_GLOBAL_PERMS)),
|
||||
formatBoolean(c.get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS)),
|
||||
formatBoolean(c.get(ConfigKeys.APPLYING_GLOBAL_GROUPS)),
|
||||
|
@ -28,6 +28,7 @@ import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.List;
|
||||
@ -44,13 +45,21 @@ public class NetworkSyncCommand extends SingleCommand {
|
||||
plugin.getUpdateTaskBuffer().request().join();
|
||||
Message.UPDATE_TASK_COMPLETE_NETWORK.send(sender);
|
||||
|
||||
if (plugin.getMessagingService() != null) {
|
||||
plugin.getMessagingService().pushUpdate();
|
||||
Message.UPDATE_TASK_PUSH_SUCCESS.send(sender);
|
||||
} else {
|
||||
Message.UPDATE_TASK_PUSH_FAILURE.send(sender);
|
||||
InternalMessagingService messagingService = plugin.getMessagingService();
|
||||
|
||||
if (messagingService == null) {
|
||||
Message.UPDATE_TASK_PUSH_FAILURE_NOT_SETUP.send(sender);
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
try {
|
||||
messagingService.pushUpdate();
|
||||
Message.UPDATE_TASK_PUSH_SUCCESS.send(sender, messagingService.getName());
|
||||
return CommandResult.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.UPDATE_TASK_PUSH_FAILURE.send(sender);
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,8 +138,9 @@ public enum Message {
|
||||
UPDATE_TASK_REQUEST("&bUpdate task scheduled.", true),
|
||||
UPDATE_TASK_COMPLETE("&aUpdate task finished.", true),
|
||||
UPDATE_TASK_COMPLETE_NETWORK("&aUpdate task finished. Now attempting to push to other servers.", true),
|
||||
UPDATE_TASK_PUSH_SUCCESS("&aOther servers were notified successfully.", true),
|
||||
UPDATE_TASK_PUSH_FAILURE("&cError whilst pushing changes to other servers. Is Redis enabled?", true),
|
||||
UPDATE_TASK_PUSH_SUCCESS("&aOther servers were notified via &b{0} Messaging &asuccessfully.", true),
|
||||
UPDATE_TASK_PUSH_FAILURE("&cError whilst pushing changes to other servers.", true),
|
||||
UPDATE_TASK_PUSH_FAILURE_NOT_SETUP("&cError whilst pushing changes to other servers. A messaging service has not been configured.", true),
|
||||
RELOAD_CONFIG_SUCCESS("&aThe configuration file was reloaded. &7(some options will only apply after the server has restarted.)", true),
|
||||
INFO(
|
||||
"{PREFIX}&2Running &bLuckPerms v{0}&2 by &bLuck&2." + "\n" +
|
||||
@ -147,19 +148,19 @@ public enum Message {
|
||||
"{PREFIX}&f- &3Storage Method: &f{2}" + "\n" +
|
||||
"{PREFIX}&f- &3Server Name: &f{3}" + "\n" +
|
||||
"{PREFIX}&f- &3Sync Interval: &a{4} &fminutes" + "\n" +
|
||||
"{PREFIX}&f- &3Messaging Service: &f{5}" + "\n" +
|
||||
"{PREFIX}&f- &bCounts:" + "\n" +
|
||||
"{PREFIX}&f- &3Online Players: &a{5}" + "\n" +
|
||||
"{PREFIX}&f- &3Loaded Users: &a{6}" + "\n" +
|
||||
"{PREFIX}&f- &3Loaded Groups: &a{7}" + "\n" +
|
||||
"{PREFIX}&f- &3Loaded Tracks: &a{8}" + "\n" +
|
||||
"{PREFIX}&f- &3Log size: &a{9}" + "\n" +
|
||||
"{PREFIX}&f- &3UUID Cache size: &a{10}" + "\n" +
|
||||
"{PREFIX}&f- &3Translations loaded: &a{11}" + "\n" +
|
||||
"{PREFIX}&f- &3Pre-process contexts: &a{12}" + "\n" +
|
||||
"{PREFIX}&f- &3Context Calculators: &a{13}" + "\n" +
|
||||
"{PREFIX}&f- &3Online Players: &a{6}" + "\n" +
|
||||
"{PREFIX}&f- &3Loaded Users: &a{7}" + "\n" +
|
||||
"{PREFIX}&f- &3Loaded Groups: &a{8}" + "\n" +
|
||||
"{PREFIX}&f- &3Loaded Tracks: &a{9}" + "\n" +
|
||||
"{PREFIX}&f- &3Log size: &a{10}" + "\n" +
|
||||
"{PREFIX}&f- &3UUID Cache size: &a{11}" + "\n" +
|
||||
"{PREFIX}&f- &3Translations loaded: &a{12}" + "\n" +
|
||||
"{PREFIX}&f- &3Pre-process contexts: &a{13}" + "\n" +
|
||||
"{PREFIX}&f- &3Context Calculators: &a{14}" + "\n" +
|
||||
"{PREFIX}&f- &bConfiguration:" + "\n" +
|
||||
"{PREFIX}&f- &3Online Mode: {14}" + "\n" +
|
||||
"{PREFIX}&f- &3Redis Enabled: {15}" + "\n" +
|
||||
"{PREFIX}&f- &3Online Mode: {15}" + "\n" +
|
||||
"{PREFIX}&f- &bPermission Calculation:" + "\n" +
|
||||
"{PREFIX}&f- &3Including Global: {16}" + "\n" +
|
||||
"{PREFIX}&f- &3Including Global World: {17}" + "\n" +
|
||||
|
@ -22,9 +22,9 @@
|
||||
|
||||
package me.lucko.luckperms.common.messaging;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import me.lucko.luckperms.api.MessagingService;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -37,16 +37,16 @@ import java.util.function.Consumer;
|
||||
* An abstract implementation of {@link me.lucko.luckperms.api.MessagingService}.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public abstract class AbstractMessagingService implements MessagingService {
|
||||
public abstract class AbstractMessagingService implements InternalMessagingService {
|
||||
public static final String CHANNEL = "lpuc";
|
||||
|
||||
private final LuckPermsPlugin plugin;
|
||||
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
private final Set<UUID> receivedMsgs = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
public abstract void close();
|
||||
|
||||
protected abstract void sendMessage(String channel, String message);
|
||||
|
||||
protected void onMessage(String channel, String msg, Consumer<UUID> callback) {
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.messaging;
|
||||
|
||||
import me.lucko.luckperms.api.MessagingService;
|
||||
|
||||
public interface InternalMessagingService extends MessagingService {
|
||||
|
||||
String getName();
|
||||
void close();
|
||||
|
||||
}
|
@ -96,8 +96,9 @@ track-empty: "The track cannot be used as it is empty or contains only one group
|
||||
update-task-request: "&bUpdate task scheduled."
|
||||
update-task-complete: "&aUpdate task finished."
|
||||
update-task-complete-network: "&aUpdate task finished. Now attempting to push to other servers."
|
||||
update-task-push-success: "&aOther servers were notified successfully."
|
||||
update-task-push-failure: "&cError whilst pushing changes to other servers. Is Redis enabled?"
|
||||
update-task-push-success: "&aOther servers were notified via &b{0} Messaging &asuccessfully."
|
||||
update-task-push-failure: "&cError whilst pushing changes to other servers."
|
||||
update-task-push-failure-not-setup: "&cError whilst pushing changes to other servers. A messaging service has not been configured."
|
||||
reload-config-success: "&aThe configuration file was reloaded. &7(some options will only apply after the server has restarted.)"
|
||||
info: >
|
||||
{PREFIX}&2Running &bLuckPerms v{0}&2 by &bLuck&2.\n
|
||||
@ -105,19 +106,19 @@ info: >
|
||||
{PREFIX}&f- &3Storage Method: &f{2}\n
|
||||
{PREFIX}&f- &3Server Name: &f{3}\n
|
||||
{PREFIX}&f- &3Sync Interval: &a{4} &fminutes\n
|
||||
{PREFIX}&f- &3Messaging Service: &f{5}\n
|
||||
{PREFIX}&f- &bCounts:\n
|
||||
{PREFIX}&f- &3Online Players: &a{5}\n
|
||||
{PREFIX}&f- &3Loaded Users: &a{6}\n
|
||||
{PREFIX}&f- &3Loaded Groups: &a{7}\n
|
||||
{PREFIX}&f- &3Loaded Tracks: &a{8}\n
|
||||
{PREFIX}&f- &3Log size: &a{9}\n
|
||||
{PREFIX}&f- &3UUID Cache size: &a{10}\n
|
||||
{PREFIX}&f- &3Translations loaded: &a{11}\n
|
||||
{PREFIX}&f- &3Pre-process contexts: &a{12}\n
|
||||
{PREFIX}&f- &3Context Calculators: &a{13}\n
|
||||
{PREFIX}&f- &3Online Players: &a{6}\n
|
||||
{PREFIX}&f- &3Loaded Users: &a{7}\n
|
||||
{PREFIX}&f- &3Loaded Groups: &a{8}\n
|
||||
{PREFIX}&f- &3Loaded Tracks: &a{9}\n
|
||||
{PREFIX}&f- &3Log size: &a{10}\n
|
||||
{PREFIX}&f- &3UUID Cache size: &a{11}\n
|
||||
{PREFIX}&f- &3Translations loaded: &a{12}\n
|
||||
{PREFIX}&f- &3Pre-process contexts: &a{13}\n
|
||||
{PREFIX}&f- &3Context Calculators: &a{14}\n
|
||||
{PREFIX}&f- &bConfiguration:\n
|
||||
{PREFIX}&f- &3Online Mode: {14}\n
|
||||
{PREFIX}&f- &3Redis Enabled: {15}\n
|
||||
{PREFIX}&f- &3Online Mode: {15}\n
|
||||
{PREFIX}&f- &bPermission Calculation:\n
|
||||
{PREFIX}&f- &3Including Global: {16}\n
|
||||
{PREFIX}&f- &3Including Global World: {17}\n
|
||||
@ -125,7 +126,7 @@ info: >
|
||||
{PREFIX}&f- &3Applying Global World Groups: {19}\n
|
||||
{PREFIX}&f- &3Applying Wildcards: {20}\n
|
||||
{PREFIX}&f- &3Applying Regex: {21}\n
|
||||
{PREFIX}&f- &3Applying Shorthand: {22}"
|
||||
{PREFIX}&f- &3Applying Shorthand: {22}
|
||||
create-group-error: "There was an error whilst creating the group."
|
||||
delete-group-error: "There was an error whilst deleting the group."
|
||||
delete-group-error-default: "You cannot delete the default group."
|
||||
|
@ -51,7 +51,7 @@ import me.lucko.luckperms.common.locale.NoopLocaleManager;
|
||||
import me.lucko.luckperms.common.locale.SimpleLocaleManager;
|
||||
import me.lucko.luckperms.common.managers.TrackManager;
|
||||
import me.lucko.luckperms.common.managers.impl.GenericTrackManager;
|
||||
import me.lucko.luckperms.common.messaging.AbstractMessagingService;
|
||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||
import me.lucko.luckperms.common.messaging.RedisMessaging;
|
||||
import me.lucko.luckperms.common.storage.Storage;
|
||||
import me.lucko.luckperms.common.storage.StorageFactory;
|
||||
@ -148,7 +148,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
private SpongeGroupManager groupManager;
|
||||
private TrackManager trackManager;
|
||||
private Storage storage;
|
||||
private AbstractMessagingService messagingService = null;
|
||||
private InternalMessagingService messagingService = null;
|
||||
private UuidCache uuidCache;
|
||||
private ApiProvider apiProvider;
|
||||
private me.lucko.luckperms.api.Logger log;
|
||||
|
Loading…
Reference in New Issue
Block a user