勤劳的鸽子
本帖最后由 勤劳的鸽子 于 2023-2-12 11:34 编辑

我让ChatGPT为我编写了一个插件!




主类代码如下!
(他甚至可以生成配方为空气时返回的语句)


我作为一个入门级开发者已经在瑟瑟发抖了....
什么?你看不懂?没关系ChatGPT经过测试还可以给插件加入注解...






teddyxlandlee
你这ChatGPT是抄了多少开源插件才生成出这么完善的代码啊(恼)

小林~
ChatGPT这么强的吗?

Stone_ingot
我的评价是:进阶CV大法(

LinGCar
因为本人没学过插件开发 以下内容如有解释错误 轻喷(

public class RecipeAdder extends JavaPlugin implements Listener

声明插件主类RecipeAdder,Listener表明此为一个监听者类

public void onEnable()

这个方**在插件启动的时候被调用。

saveDefaultConfig();
FileConfiguarion config = getConfig();

获取配置文件 但是我并没有找到这俩方法的实现(((

for (String key : config.getConfigurationSection("recipes").getKeys(false)) {
            ShapedRecipe recipe = new ShapedRecipe(new ItemStack(Material.getMaterial(config.getString(key + ".result.type"))));
            recipe.shape(config.getString(key + ".shape.row1"), config.getString(key + ".shape.row2"), config.getString(key + ".shape.row3"));
            for (String ingredientKey : config.getConfigurationSection(key + ".ingredients").getKeys(false)) {
                recipe.setIngredient(ingredientKey.charAt(0), Material.getMaterial(config.getString(key + ".ingredients." + ingredientKey)));
            }
            Bukkit.addRecipe(recipe);
        }

也许是添加配方 但是我没写过(


Re:alize
就算真的能用它写 自己看不懂的情况下搞不好会有一大堆奇怪的bug

勤劳的鸽子
LinGCar 发表于 2023-2-12 08:55
因为本人没学过插件开发 以下内容如有解释错误 轻喷(

嗯,经过测试确实可以运行,但是自定义配方有亿点问题,而且写入的是弃用的方法

勤劳的鸽子
Re:alize 发表于 2023-2-12 09:13
就算真的能用它写 自己看不懂的情况下搞不好会有一大堆奇怪的bug

放心,他甚至可以生成注解

LinGCar
勤劳的鸽子 发表于 2023-2-12 09:16
放心,他甚至可以生成注解

这东西鬼知道抄了多少开源代码(((
搞不好出个许可冲突就麻烦了((

下一页 最后一页