當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuListener類代碼示例

本文整理匯總了Java中com.dsh105.echopet.listeners.MenuListener的典型用法代碼示例。如果您正苦於以下問題:Java MenuListener類的具體用法?Java MenuListener怎麽用?Java MenuListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MenuListener類屬於com.dsh105.echopet.listeners包,在下文中一共展示了MenuListener類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onEnable

import com.dsh105.echopet.listeners.MenuListener; //導入依賴的package包/類
@Override
@SneakyThrows(IOException.class)
public void onEnable() {
    EchoPet.setPlugin(this);
    isUsingNetty = CommonReflection.isUsingNetty();

    this.configManager = new YAMLConfigManager(this);
    COMMAND_MANAGER = new CommandManager(this);
    // Make sure that the plugin is running under the correct version to prevent errors

    if (NmsVersion.current() == null || !INMS.isSupported()) {
        EchoPet.LOG.log(ChatColor.RED + "SonarPet " + ChatColor.GOLD
                + this.getDescription().getVersion() + ChatColor.RED
                + " is not compatible with this version of CraftBukkit");
        EchoPet.LOG.log(ChatColor.RED + "Initialisation failed. Please update the plugin.");

        DynamicPluginCommand cmd = new DynamicPluginCommand(this.cmdString, new String[0], "", "",
                new VersionIncompatibleCommand(this, this.cmdString, ChatColor.YELLOW +
                        "SonarPet " + ChatColor.GOLD + this.getDescription().getVersion() + ChatColor.YELLOW + " is not compatible with this version of CraftBukkit. Please update the plugin.",
                        "echopet.pet", ChatColor.YELLOW + "You are not allowed to do that."),
                null, this);
        COMMAND_MANAGER.register(cmd);
        return;
    }
    EntityRegistry entityRegistry;
    if (CitizensEntityRegistryHack.isNeeded()) {
        getLogger().warning("Attempting to inject citizens compatibility hack....");
        entityRegistry = CitizensEntityRegistryHack.createInstance();
        getLogger().warning("Successfully injected citizens compatibility hack!");
    } else {
        //noinspection deprecation // We check for citizens first ;)
        entityRegistry = INMS.getInstance().createDefaultEntityRegistry();
    }
    this.entityRegistry = Objects.requireNonNull(entityRegistry);

    this.loadConfiguration();

    PluginManager manager = getServer().getPluginManager();

    MANAGER = new PetManager();
    SQL_MANAGER = new SqlPetManager();

    if (OPTIONS.useSql()) {
        this.prepareSqlDatabase();
    }

    // Register custom commands
    // Command string based off the string defined in config.yml
    // By default, set to 'pet'
    // PetAdmin command draws from the original, with 'admin' on the end
    this.cmdString = OPTIONS.getCommandString();
    this.adminCmdString = OPTIONS.getCommandString() + "admin";
    DynamicPluginCommand petCmd = new DynamicPluginCommand(this.cmdString, new String[0], "Create and manage your own custom pets.", "Use /" + this.cmdString + " help to see the command list.", new PetCommand(this.cmdString), null, this);
    petCmd.setTabCompleter(new CommandComplete());
    COMMAND_MANAGER.register(petCmd);
    COMMAND_MANAGER.register(new DynamicPluginCommand(this.adminCmdString, new String[0], "Create and manage the pets of other players.", "Use /" + this.adminCmdString + " help to see the command list.", new PetAdminCommand(this.adminCmdString), null, this));

    // Initialize hook classes
    for (ClassPath.ClassInfo hookType : ClassPath.from(getClass().getClassLoader()).getTopLevelClasses("net.techcable.sonarpet.nms.entity.type")) {
        if (!hookType.load().isAnnotationPresent(EntityHook.class)) continue;
        for (EntityHookType type : hookType.load().getAnnotation(EntityHook.class).value()) {
            if (!type.isActive()) continue;
            hookRegistry.registerHookClass(type, hookType.load().asSubclass(IEntityPet.class));
        }
    }

    // Register listeners
    manager.registerEvents(new MenuListener(), this);
    manager.registerEvents(new PetEntityListener(this), this);
    manager.registerEvents(new PetOwnerListener(), this);
    if (VersionNotificationListener.isNeeded()) {
        manager.registerEvents(new VersionNotificationListener(), this);
        PluginVersioning.INSTANCE.sendOutdatedVersionNotification(Bukkit.getConsoleSender());
    }
    //manager.registerEvents(new ChunkListener(), this);

    this.vanishProvider = new VanishProvider(this);
    this.worldGuardProvider = new WorldGuardProvider(this);
}
 
開發者ID:TechzoneMC,項目名稱:SonarPet,代碼行數:80,代碼來源:EchoPetPlugin.java


注:本文中的com.dsh105.echopet.listeners.MenuListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。