All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mrivanplays.bungee.messaging.MessagingAPI Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2019 Ivan Pekov
 *
 * 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 NON INFRINGEMENT. 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 com.github.mrivanplays.bungee.messaging;

import com.github.mrivanplays.bungee.messaging.api.BungeeMessagingAPI;
import org.apache.commons.lang.Validate;
import org.bukkit.plugin.Plugin;

/** Represents a getter of {@link BungeeMessagingAPI} */
@SuppressWarnings("unused")
public abstract class MessagingAPI {
  /** Represents an instance of this class * */
  private static MessagingAPI instance;

  /**
   * Gets instance of this class
   *
   * @return instance of this class
   */
  public static MessagingAPI getInstance() {
    return instance;
  }

  /**
   * Sets a new instance of this class
   *
   * @param instance new instance
   */
  public static void setInstance(MessagingAPI instance) {
    Validate.notNull(instance, "New instance cannot be null");
    if (MessagingAPI.instance != null) {
      throw new IllegalArgumentException("Instance of MessagingAPI already set.");
    }
    MessagingAPI.instance = instance;
  }

  /**
   * Gets the messenger of the specified {@link Plugin}
   *
   * @param plugin specified plugin messenger
   * @return specified plugin {@link BungeeMessagingAPI} messenger
   */
  public abstract BungeeMessagingAPI getMessenger(Plugin plugin);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy