org.bukkit.Bukkit.getPluginManager()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(240)

本文整理了Java中org.bukkit.Bukkit.getPluginManager()方法的一些代码示例,展示了Bukkit.getPluginManager()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bukkit.getPluginManager()方法的具体详情如下:
包路径:org.bukkit.Bukkit
类名称:Bukkit
方法名:getPluginManager

Bukkit.getPluginManager介绍

暂无

代码示例

代码示例来源:origin: Bukkit/Bukkit

private String getPluginList() {
    StringBuilder pluginList = new StringBuilder();
    Plugin[] plugins = Bukkit.getPluginManager().getPlugins();

    for (Plugin plugin : plugins) {
      if (pluginList.length() > 0) {
        pluginList.append(ChatColor.WHITE);
        pluginList.append(", ");
      }

      pluginList.append(plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED);
      pluginList.append(plugin.getDescription().getName());
    }

    return "(" + plugins.length + "): " + pluginList.toString();
  }
}

代码示例来源:origin: Bukkit/Bukkit

@Override
  public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 1) {
      List<String> completions = new ArrayList<String>();
      String toComplete = args[0].toLowerCase();
      for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
        if (StringUtil.startsWithIgnoreCase(plugin.getName(), toComplete)) {
          completions.add(plugin.getName());
        }
      }
      return completions;
    }
    return ImmutableList.of();
  }
}

代码示例来源:origin: Bukkit/Bukkit

public static Permission registerPermission(Permission perm, boolean withLegacy) {
  Permission result = perm;
  try {
    Bukkit.getPluginManager().addPermission(perm);
  } catch (IllegalArgumentException ex) {
    result = Bukkit.getPluginManager().getPermission(perm.getName());
  }
  if (withLegacy) {
    Permission legacy = new Permission(LEGACY_PREFIX + result.getName(), result.getDescription(), PermissionDefault.FALSE);
    legacy.getChildren().put(result.getName(), true);
    registerPermission(perm, false);
  }
  return result;
}

代码示例来源:origin: Bukkit/Bukkit

Plugin exactPlugin = Bukkit.getPluginManager().getPlugin(pluginName);
if (exactPlugin != null) {
  describeToSender(exactPlugin, sender);
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
  if (plugin.getName().toLowerCase().contains(pluginName)) {
    describeToSender(plugin, sender);

代码示例来源:origin: Bukkit/Bukkit

fileNames = new PrintStream(names);
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
  pluginIdx++;
  long totalTime = 0;

代码示例来源:origin: Bukkit/Bukkit

String[] split = name.split(":", 2);
String id = (split.length > 1) ? split[1] : null;
Plugin plugin = Bukkit.getPluginManager().getPlugin(split[0]);

代码示例来源:origin: Bukkit/Bukkit

@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
  if (!testPermission(sender)) return true;
  if (sender instanceof Player) {
    Player player = (Player) sender;
    EntityDamageEvent ede = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.SUICIDE, 1000);
    Bukkit.getPluginManager().callEvent(ede);
    if (ede.isCancelled()) return true;
    ede.getEntity().setLastDamageCause(ede);
    player.setHealth(0);
    sender.sendMessage("Ouch. That look like it hurt.");
  } else {
    sender.sendMessage("You can only perform this command as a player");
  }
  return true;
}

代码示例来源:origin: Bukkit/Bukkit

Set<Permissible> users = Bukkit.getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
String colored = ChatColor.GRAY + "" + ChatColor.ITALIC + "[" + result + ChatColor.GRAY + ChatColor.ITALIC + "]";

代码示例来源:origin: GlowstoneMC/Glowstone

sendBullet(sender, t, b, "glowstone.about.worlds", Bukkit.getWorlds().size());
sendBullet(sender, t, b, "glowstone.about.plugins",
    Bukkit.getPluginManager().getPlugins().length);

代码示例来源:origin: EngineHub/WorldGuard

BukkitPlayer(WorldGuardPlugin plugin, Player player, boolean silenced) {
  super((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"), player);
  this.plugin = plugin;
  this.silenced = silenced;
}

代码示例来源:origin: com.github.shynixn.petblocks/petblocks-bukkit-lib

/**
 * Initializes a new listener by pluginname
 *
 * @param plugin plugin
 */
public SimpleListener(String plugin) {
  this(Bukkit.getPluginManager().getPlugin(plugin));
}

代码示例来源:origin: com.github.shynixn.petblocks/petblocks-bukkit-lib

/**
 * Registers the listener to spigot
 */
final void register() {
  Bukkit.getPluginManager().registerEvents(this, this.plugin);
}

代码示例来源:origin: com.github.shynixn.ball/ball-bukkit-core

/**
 * Registers the listener to spigot
 */
final void register() {
  Bukkit.getPluginManager().registerEvents(this, this.plugin);
}

代码示例来源:origin: MylesIsCool/ViaVersion

@Override
public JsonObject getDump() {
  JsonObject platformSpecific = new JsonObject();
  List<PluginInfo> plugins = new ArrayList<>();
  for (Plugin p : Bukkit.getPluginManager().getPlugins())
    plugins.add(new PluginInfo(p.isEnabled(), p.getDescription().getName(), p.getDescription().getVersion(), p.getDescription().getMain(), p.getDescription().getAuthors()));
  platformSpecific.add("plugins", GsonUtil.getGson().toJsonTree(plugins));
  // TODO more? ProtocolLib things etc?
  return platformSpecific;
}

代码示例来源:origin: EngineHub/WorldGuard

@Override
public void broadcastNotification(String message) {
  Bukkit.broadcast(message, "worldguard.notify");
  Set<Permissible> subs = Bukkit.getPluginManager().getPermissionSubscriptions("worldguard.notify");
  for (Player player : Bukkit.getServer().getOnlinePlayers()) {
    if (!(subs.contains(player) && player.hasPermission("worldguard.notify")) &&
        WorldGuardPlugin.inst().hasPermission(player, "worldguard.notify")) { // Make sure the player wasn't already broadcasted to.
      player.sendMessage(message);
    }
  }
  WorldGuard.logger.info(message);
}

代码示例来源:origin: MylesIsCool/ViaVersion

@Override
public void onReload() {
  if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
    getLogger().severe("ViaVersion is already loaded, we're going to kick all the players... because otherwise we'll crash because of ProtocolLib.");
    for (Player player : Bukkit.getOnlinePlayers()) {
      player.kickPlayer(ChatColor.translateAlternateColorCodes('&', getConf().getReloadDisconnectMsg()));
    }
  } else {
    getLogger().severe("ViaVersion is already loaded, this should work fine. If you get any console errors, try rebooting.");
  }
}

代码示例来源:origin: Multiverse/Multiverse-Core

/**
   * {@inheritDoc}
   */
  @Override
  public T validateChange(String property, T newValue, T oldValue, MVWorld object) throws ChangeDeniedException {
    MVWorldPropertyChangeEvent<T> event = new MVWorldPropertyChangeEvent<T>(object, null, property, newValue);
    Bukkit.getPluginManager().callEvent(event);
    if (event.isCancelled())
      throw new ChangeDeniedException();
    return event.getTheNewValue();
  }
}

代码示例来源:origin: ProtocolSupport/ProtocolSupport

@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
  super.channelInactive(ctx);
  Bukkit.getPluginManager().callEvent(new ConnectionCloseEvent(connection));
  ProtocolStorage.removeConnection(connection.getRawAddress());
}

代码示例来源:origin: com.github.shynixn.ball/ball-bukkit-core

/**
 * Removes the ball.
 */
@Override
public void remove() {
  Bukkit.getPluginManager().callEvent(new BallDeathEvent(this));
  this.deGrab();
  this.getSpigotEntity().remove();
  this.hitBox.getSpigotEntity().remove();
}

代码示例来源:origin: com.github.shynixn.ball/ball-bukkit-core

/**
 * Removes the ball.
 */
@Override
public void remove() {
  Bukkit.getPluginManager().callEvent(new BallDeathEvent(this));
  this.deGrab();
  this.getSpigotEntity().remove();
  this.hitBox.getSpigotEntity().remove();
}

相关文章