如何让自己写的插件支持papi,比如聊天插件,我需要他在配置文件里面填写格式,他用到了papi变量,我插件应该如何支持
 本帖最后由 冰星 于 2020-6-29 09:21 编辑 
从wiki入手https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
从wiki入手https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
- 如果你只是想单纯的用其他插件注册的变量,那么只需要将papi作为依赖即可,并在需要替换变量的地方写上PlaceholderAPI.setPlaceholders(替换内容, "待替换文本");
- 如果你想自己为自己插件的注册变量,那么你需要新建一个类,并且这个类要继承于PlaceholderExpansion,并重写以下方法
- 最重要的一步是,不要忘记在你的主类启动时注册这个类,复制代码- /**
 
-      * This method should always return true unless we
 
-      * have a dependency we need to make sure is on the server
 
-      * for our placeholders to work!
 
-      *
 
-      * @return always true since we do not have any dependencies.
 
-      */
 
-     @Override
 
-     public boolean canRegister(){
 
-         return true;
 
-     }
 
 
-     /**
 
-      * The name of the person who created this expansion should go here.
 
-      * 
 
-      * @return The name of the author as a String.
 
-      */
 
-     @Override
 
-     public String getAuthor(){
 
-         return "someauthor";
 
-     }
 
 
-     /**
 
-      * The placeholder identifier should go here.
 
-      * <br>This is what tells PlaceholderAPI to call our onRequest 
 
-      * method to obtain a value if a placeholder starts with our 
 
-      * identifier.
 
-      * <br>This must be unique and can not contain % or _
 
-      *
 
-      * @return The identifier in {@code %<identifier>_<value>%} as String.
 
-      */
 
-     @Override
 
-     public String getIdentifier(){
 
-         return "example";
 
-     }
 
 
-     /**
 
-      * This is the version of this expansion.
 
-      * <br>You don't have to use numbers, since it is set as a String.
 
-      *
 
-      * @return The version as a String.
 
-      */
 
-     @Override
 
-     public String getVersion(){
 
-         return "1.0.0";
 
-     }
 
-   
 
-     /**
 
-      * This is the method called when a placeholder with our identifier 
 
-      * is found and needs a value.
 
-      * <br>We specify the value identifier in this method.
 
-      * <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
 
-      *
 
-      * @param  player
 
-      *         A {@link org.bukkit.OfflinePlayer OfflinePlayer}.
 
-      * @param  identifier
 
-      *         A String containing the identifier/value.
 
-      *
 
-      * @return Possibly-null String of the requested identifier.
 
-      */
 
-     @Override
 
-     public String onRequest(OfflinePlayer player, String identifier){
 
-   
 
-         // %example_placeholder1%
 
-         if(identifier.equals("placeholder1")){
 
-             return "placeholder1 works";
 
-         }
 
 
-         // %example_placeholder2%
 
-         if(identifier.equals("placeholder2")){
 
-             return "placeholder2 works";
 
-         }
 
 
-         // We return null if an invalid placeholder (f.e. %example_placeholder3%) 
 
-         // was provided
 
-         return null;
 
- }
   
 
- /**
冰星 发表于 2020-6-29 09:15
从wiki入手https://github.com/PlaceholderAPI/PlaceholderAPI/wiki如果你只是想单纯的用其他插件注册 ... 
大佬可以加个Q吗,我不是很懂 (麻烦啦