居然还播报了网易版的动态,好勤勉。
网易不使用neoforge也很正常,因为他们有几个重要的基于forge开发的启动器支持mod,应该抽不出时间去做移植,不是那么方便上neoforge。
混乱Chaos 发布的最新帖子
-
RE: 自制MC新闻周报 第43期
-
我找deepseek问如何在MC服务器部署deepseek,有没有开发者看看他纯扯淡还是真能跑?
以下是他给的步骤:
在《我的世界》中实现与DeepSeek对话需要结合Minecraft插件开发和API调用,以下是分步部署方案:
第一步:环境准备
-
服务器端
- 安装Java 17+运行环境
- 部署支持插件的服务端(推荐选择):
- PaperMC(高性能优化版): https://papermc.io
- Spigot/Bukkit(经典插件框架)
-
开发工具
- IDE:IntelliJ IDEA(推荐)或 Eclipse
- 构建工具:Maven或Gradle
- 插件开发库:Spigot API / Paper API
第二步:插件开发
1. 创建基础插件
// 示例:主类注册事件监听 public class DeepSeekPlugin extends JavaPlugin { @Override public void onEnable() { getServer().getPluginManager().registerEvents(new ChatListener(), this); getLogger().info("DeepSeek对话插件已激活"); } }
2. 实现聊天监听
public class ChatListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onPlayerChat(AsyncPlayerChatEvent event) { if (event.getMessage().startsWith("!deepseek ")) { String query = event.getMessage().substring(10
第三步:API通信核心实现
1. 添加HTTP请求依赖(Maven配置)
<dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.13</version> </dependency>
2. 实现DeepSeek API调用(示例)
public class DeepSeekAPI { private static final String API_URL = "https://api.deepseek.com/v1/chat/completions"; private final String apiKey; public DeepSeekAPI(String apiKey) { this.apiKey = apiKey; } public String getResponse(String prompt) throws IOException { try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpPost httpPost = new HttpPost(API_URL); // 构建JSON请求体 JSONObject json = new JSONObject(); json.put("model", "deepseek-chat"); json.put("messages", new JSONArray().put(new JSONObject() .put("role", "user") .put("content", prompt))); // 设置请求头 httpPost.setHeader("Content-Type", "application/json"); httpPost.setHeader("Authorization", "Bearer " + apiKey); httpPost.setEntity(new StringEntity(json.toString())); // 执行请求并解析响应 try (CloseableHttpResponse response = httpClient.execute(httpPost)) { String responseBody = EntityUtils.toString(response.getEntity()); JSONObject responseJson = new JSONObject(responseBody); return responseJson.getJSONArray("choices") .getJSONObject(0) .getJSONObject("message") .getString("content"); } } } }
第四步:完整插件集成
1. 配置API密钥(plugin.yml)
name: DeepSeekChat version: 1.0 main: com.yourpackage.DeepSeekPlugin api-version: 1.17 commands: deepseek: description: 与DeepSeek对话
2. 异步处理改造(防止阻塞主线程)
@EventHandler public void onPlayerChat(AsyncPlayerChatEvent event) { if (event.getMessage().startsWith("!deepseek ")) { event.setCancelled(true); // 取消原始聊天广播 Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { try { String response = new DeepSeekAPI(plugin.getConfig().getString("api-key")) .getResponse(event.getMessage().substring(10)); // 同步返回消息到游戏内 Bukkit.getScheduler().runTask(plugin, () -> event.getPlayer().sendMessage("§bDeepSeek §7» §f" + response)); } catch (Exception e) { event.getPlayer().sendMessage("§c请求失败: " + e.getMessage()); } }); } }
第五步:部署配置
- 创建配置文件
config.yml
api-key: "your_deepseek_api_key_here" rate-limit: 5 # 每秒请求限制
- 插件加载配置
public void onEnable() { saveDefaultConfig(); reloadConfig(); }
关键注意事项
-
API密钥安全
- 通过
config.yml
存储密钥,切勿硬编码在代码中 - 设置服务器
ops.json
权限控制
- 通过
-
异步处理
- 必须使用
runTaskAsynchronously
避免阻塞主线程 - 游戏内消息回传需切换回主线程(
runTask
)
- 必须使用
-
错误处理
try { // API调用代码 } catch (IOException e) { getLogger().log(Level.SEVERE, "API通信失败", e); } catch (JSONException e) { getLogger().warning("API响应解析异常"); }
高级扩展建议
- 添加冷却时间限制
CooldownManager cooldowns = new CooldownManager(30); // 30秒冷却 if (cooldowns.checkCooldown(player)) { player.sendMessage("§c请等待 " + cooldowns.getRemaining(player) + "秒后再使用"); return; }
- 支持多语言响应
// 在API请求中添加语言参数 json.put("language", getConfig().getString("language", "zh-CN"));
- 日志记录
new BukkitRunnable() { public void run() { logToDatabase(player.getName(), query, response); } }.runTaskAsynchronously(plugin);
完成以上步骤后,通过
mvn clean package
构建插件,将生成的.jar
文件放入服务器的plugins
目录并重启服务器即可使用。 -
-
RE: 【闲聊】一些碎碎念
@IF_IceFire 没啥毛病,就这么一回事。当然以前读书馆进馆手续多,旧书库还需要额外通行手续,一次只能看一本,而且很多书需要你写评论才能看,再加上图书管理员仗着有权限,经常禁止一些素质不好的人访问图书馆、并且不让商业刊物随便入库、商业刊物出版者还记恨图书馆各种限制、时不时对图书馆进行攻击;所以很多人因此记恨。
-
RE: 关于实名认证法规相关
@happy重生锚 因为手机号在实际情况中很难锁定违法犯罪者,存在虚拟手机号、业务用无实名手机号、盗用他人手机号等规避情况,其仿冒成本相比于实名认证要低得多。