GunPlugin - 枪械插件
一个功能丰富的Minecraft枪械插件,支持多种枪械类型、自定义配置、真实弹道系统和完整的射击体验。
A feature-rich Minecraft gun plugin with multiple weapon types, custom configuration, realistic ballistics system, and complete shooting experience.
📋 目录 / Table of Contents
- 功能特性 / Features
- 安装指南 / Installation
- 配置说明 / Configuration
- 命令列表 / Commands
- 权限系统 / Permissions
- 枪械目录 / Weapon catalog
- 自定义枪械 / Custom Weapons
- 更新日志 / Changelog
- 常见问题 / FAQ
- 技术支持 / Support
🚀 功能特性 / Features
核心功能 / Core Features
- 多种枪械类型 / Multiple Weapon Types: 手枪、步枪、霰弹枪、狙击枪
- 真实弹道系统 / Realistic Ballistics: 子弹速度、重力下坠、穿透效果
- 弹药管理系统 / Ammunition System: 弹匣容量、换弹机制、弹药显示
- 射击模式 / Firing Modes: 单发、连发、霰弹枪多发
- 后坐力系统 / Recoil System: 视觉反馈和粒子效果
- 爆头检测 / Headshot Detection: 30%额外伤害
- 血雾效果 / Blood Effects: 击中实体的粒子效果
高级功能 / Advanced Features
- 自定义枪械 / Custom Weapons: 通过配置文件创建自定义枪械
- 子弹散步 / Bullet Spread: 移动时增加散步,鼓励静止射击
- 音效系统 / Sound System: 多层次延迟音效,增强沉浸感
- 交互禁用 / Interaction Disable: 持枪时禁用左键攻击和右键交互
- 自动射击 / Auto Fire: 按住右键连续射击,松开停止
- 手动换弹 / Manual Reload: F键手动换弹功能
📦 安装指南 / Installation
系统要求 / Requirements
- Minecraft版本 / Minecraft Version: 1.21.4
- 服务器类型 / Server Type: Spigot/Paper
- Java版本 / Java Version: 8 或更高版本 / 8 or higher
- 内存要求 / Memory: 建议2GB以上 / Recommended 2GB+
安装步骤 / Installation Steps
-
下载插件 / Download Plugin
# 将GunPlugin.jar放入服务器的plugins文件夹 # Place GunPlugin.jar in your server's plugins folder -
启动服务器 / Start Server
# 重启服务器以加载插件 # Restart your server to load the plugin -
配置插件 / Configure Plugin
# 编辑plugins/GunPlugin/config.yml文件 # Edit plugins/GunPlugin/config.yml file -
设置权限 / Set Permissions
# 给玩家gunplugin.use权限 # Give players gunplugin.use permission
⚙️ 配置说明 / Configuration
配置文件分工 / Config File Roles
| 文件 / File | 路径 / Path | 作用 / Purpose |
|---|---|---|
| guns.yml | plugins/GunPlugin/guns.yml |
枪械目录:每把枪的完整定义(伤害、rate、弹匣、换弹、sounds、recoil、category/behavior 等)。根键名即枪械 ID。 |
| config.yml | plugins/GunPlugin/config.yml |
插件与商店:settings、购买与经济 buy_system、default_guns 单枪覆盖、配件价格等。 |
修改 guns.yml 或 config.yml 后请执行 /gun reload(需权限)或重启服务端。
基础配置示例 / Basic config.yml excerpt
settings:
disable_left_click: true
disable_right_click_interaction: true
debug_mode: false
# 可选:按枪械 ID 覆盖部分属性(材质、名称、射速等),详见 config 内注释
# default_guns:
# ak74:
# fire_rate: 580 # RPM;≤4 的小数可按「秒/发」解析(见配置注释)
枪械本体 不在 config.yml 的 guns: 下列出(旧版示例已废弃);请使用 guns.yml。
📝 命令列表 / Commands
以下为 GunCommand 实际注册的子命令(见源码);整条 /gun … 在执行器中统一校验 gunplugin.admin,控制台给予弹药需使用该权限。
基础命令 / Basic Commands
| 命令 / Command | 描述 / Description |
|---|---|
/gun give <目标> <guns.yml 枪械 ID \| 弹药 \| 投掷物> [数量] |
给予枪械 / 弹药 / 投掷物(枪械 ID 与 guns.yml 根键一致;别名如 pistol→p250 见帮助) |
/gun ammo |
主手持枪:查看当前弹药 |
/gun ammo reload |
主手持枪:执行换弹 |
/gun reload |
重载插件配置与 guns.yml(不是游戏内换弹) |
/gun help |
显示帮助 |
/gun lang | /gun lang <代码> |
查看或切换语言(可用代码见语言管理器) |
/gun modify | /gun mod |
主手持枪:打开 配件改装 GUI |
/gun buy |
打开购买 GUI(需在 config 中启用购买系统) |
命令示例 / Command Examples
/gun give @p ak74
/gun give @p 9mm 64
/gun give PlayerName grenade 5
/gun ammo
/gun ammo reload
/gun reload
/gun modify
/gun buy
🔐 权限系统 / Permissions
plugin.yml 中仅声明:
| 权限 / Permission | 描述 / Description | 默认 / Default |
|---|---|---|
gunplugin.use |
在游戏内使用枪械(射击、开镜、交互等) | true |
gunplugin.admin |
使用 /gun 全部子命令(默认 OP) |
op |
权限配置示例 / Permission Configuration Example
groups:
default:
permissions:
- gunplugin.use
admin:
permissions:
- gunplugin.admin
- gunplugin.use
🔫 枪械目录 / Weapon catalog
默认及自定义枪械均由 plugins/GunPlugin/guns.yml 定义(根键即枪械 ID)。数值、别名与列表说明见该文件及仓库 CHANGELOG_5.0.0.md,此处不再维护易过期的静态枪械表。
🛠️ 自定义枪械 / Custom Weapons
当前版本枪械 完全由 guns.yml 数据驱动:复制任意现有枪械条目,修改 根键名(=枪械 ID,建议小写)并按需改字段即可新增一枪。
步骤 / Steps
-
编辑
plugins/GunPlugin/guns.yml- 根键:枪械 ID,用于
/gun give <id>、商店、物品 PDCgun_catalog_id。 - 必填字段(缺一不可):
material、display_name、damage、rate(RPM)、magazine、reload_duration(或reload_speed)、fly_speed、bullet_drop、penetration、movement_spread、ammo、is_automatic、is_shotgun、is_sniper、category、reload_mode、bolt_after_shot、attachments、sounds(含fire/reload/bolt,可为[])、recoil。 - 可选:
behavior(pistol/rifle/…);不写则按category推断。 rate:每分钟发数 RPM;射击间隔(秒) ≈60 / rate。recoil:style: normal(参数式)或style: pattern+points列表(每项[水平, 垂直])。- 文件顶部有 中英文注释,逐项说明各键含义。
- 根键:枪械 ID,用于
-
(可选)覆盖而不改 guns.yml
在config.yml的default_guns.<枪械ID>下可覆盖材质、显示名、弹匣、fire_rate、射击音效、弹药类型、is_automatic等(详见该文件内注释)。 -
重载
/gun reload -
发放
/gun give <枪械ID>
注意事项 / Notes
- 同材质多枪:若多把枪共用同一
material,仅靠材质无法区分;请使用插件发放的枪(带 PDC 目录 ID),或为不同枪指定 不同材质。 - 购买价格:在
config.yml的购买相关节配置,不在guns.yml。 - 更细的字段表与音效格式说明见
guns.yml文件头 与仓库内CHANGELOG_5.0.0.md。
极简骨架示例 / Minimal skeleton(省略音效与后坐力细节时请直接复制完整条目改 ID)
# 建议复制 aa12 / ak74 等完整条目后改名修改,下列仅为结构提示
my_custom_rifle:
material: IRON_HORSE_ARMOR
display_name: "自定义步枪"
magazine: 30
damage: 5.0
rate: 600 # RPM
fly_speed: 100
bullet_drop: 0.05
reload_duration: 2.5
penetration: 1
movement_spread: 0.5
ammo: 762
is_automatic: true
is_shotgun: false
is_sniper: false
category: rifle
reload_mode: magazine
bolt_after_shot: false
attachments: []
sounds: { fire: [...], reload: [...], bolt: [] }
recoil: { style: normal, ... }
📊 更新日志 / Changelog
详见插件根目录 CHANGELOG.md(中文累计日志)、CHANGELOG_EN.md(英文)及 CHANGELOG_5.0.0.md(5.0.0 摘要)。
❓ 常见问题 / FAQ
Q: 如何获得枪械? / How to get weapons?
A: 使用命令 /gun give <枪械类型> 或通过配置文件自定义 / Use command /gun give <weapon_type> or customize via config file
Q: 为什么子弹没有伤害? / Why bullets don't deal damage?
A: 检查玩家权限和插件配置,确保子弹更新任务正常运行 / Check player permissions and plugin configuration, ensure bullet update task is running
Q: 如何自定义枪械? / How to customize weapons?
A: 在 plugins/GunPlugin/guns.yml 中新增或复制枪械条目(根键即枪械 ID),必要时用 config.yml 的 default_guns 做覆盖;执行 /gun reload。详见上文 自定义枪械。 / Edit plugins/GunPlugin/guns.yml (root key = gun id); optionally override via default_guns in config.yml; run /gun reload. See Custom Weapons.
Q: 支持哪些Minecraft版本? / Which Minecraft versions are supported?
A: 目前支持Minecraft 1.21.x / Currently supports Minecraft 1.21.x
Q: 如何调整子弹散步? / How to adjust bullet spread?
A: 在 guns.yml 中调整 movement_spread 及 recoil 相关参数 / Tune movement_spread and recoil in guns.yml
🆘 技术支持 / Support
欢迎通过 plugin.yml 中的 website(Modrinth 等发布页)反馈问题。
许可证 / License
若仓库内附有许可证文件则以该文件为准;否则请以插件发布页的授权说明为准。
享受射击的乐趣! / Enjoy the shooting experience! 🎯
All Versions
+ Add VersionAdded rebound effect to the projectile
修复了开枪时转动视角的卡顿问题
为投掷物添加了反弹效果
- 发布日期 / Release date:** 2026-05-11
## 1. 多语言支持 / Multi-Language Support
### 中文
- 扩充语言资源文件(
messages/*.yml):商店、配件、命令提示、物品 Lore、调试与日志字符串等与模板键对齐。 - 多套语种并行维护(含简体 / 英文 / 日文 / 韩文 / 繁体中文等);缺失键回退默认语言。
- 统一射速等单位在各语言下的表述(如 RPM)。
### English
- Expanded locale packs (
messages/*.yml): shop, attachments, commands, item lore, debug/log strings aligned with keys. - Multiple locales shipped (e.g. zh_CN, en_US, ja_JP, ko_KR, zh_TW); missing keys fall back to default.
- Consistent fire-rate labeling (e.g. RPM) across languages.
## 2. 配置文件大改与自定义枪械 / Configuration Overhaul & Custom Guns
### 中文
- guns.yml**:枪械完全由数据驱动(伤害、
rate(RPM)、弹匣、换弹、sounds、recoil、behavior/category等),新增枪械仅需添加条目并重载。 - config.yml**:
default_guns按枪械 ID 覆盖部分字段;购买与经济选项集中于配置。 - guns.yml** 文件头提供中英文配置说明与必填项列表。
### English
- guns.yml**: Fully data-driven guns (damage, RPM
rate, magazine, reload,sounds,recoil,behavior/category, etc.); add entries and reload. - config.yml**: Per-gun overrides via
default_guns.<id>; economy/buy settings in config. - Bilingual header docs in
guns.ymlfor required keys and sections.
## 3. 后坐力调整 / Recoil Tuning
### 中文
- recoil**:
normal参数式与pattern点列式;points为按发序循环的[水平, 垂直]。 - 区分 **movement_spread**(移动散布)与 recoil 内 **horizontal_spread / vertical_spread**(后坐视角散布)。
### English
- recoil**:
normalvspattern;pointsare cyclic[h, v]pairs per shot. - Clear separation between **movement_spread** and recoil spread fields.
## 4. 持枪移速 / Hold Move Speed
### 中文
- 持枪减速改为 **直接调整行走速度**(
setWalkSpeed),以进入持枪前速度为基准按倍率计算;开镜、射击/换弹惩罚为额外乘数,**不再使用缓慢药水**。 - guns.yml** 新增 **
hold_move_speed**(可选,默认0.88,取值(0,1]);机枪 **negev** 示例为 **0.62**(移动更慢)。
### English
- Gun-hold slowdown uses **
Player#setWalkSpeed** from a baseline captured before aiming; scoped / shoot-reload penalties multiply it—**no Slowness potions**. - guns.yml** adds **
hold_move_speed** (optional, default0.88, range(0,1]); sample **LMG**negevuses **0.62**.
## 5. 修复已知问题 / Bug Fixes & Improvements
### 中文
- 全自动射速**:按 RPM 使用固定 tick 周期连发并首发即时射击,缓解实际射速低于配置的问题。
default_guns.fire_rate**:合并进枪械解析,与 Lore 与实战一致。- 文案**:修正部分语言下 Lore 将 RPM 显示为「秒」等问题。
### English
- Full-auto cadence**: Tick-based scheduling from RPM plus immediate first shot; reduces undershoot vs configured RPM.
default_guns.fire_rate**: Applied in resolved gun stats (matches lore and gameplay).- UI copy**: Fixed RPM vs seconds in some locales.
## [4.0.0]
I forgot what I updated🤔 **我忘记更新了什么🤔……**
## [3.0.1]
Fixed the bug of material conflict between .50mm ammunition and the firearm "USP" **修复了.50mm弹药和枪械“USP”材质冲突的问题**
- 中文 / Chinese** | **English**
## 🎯 重大更新 / Major Updates
### 全面多语言适配 / Complete Multi-Language Support
#### 中文
- 完整的多语言支持**
- 所有GUI界面完全适配中英文
- 配件系统界面完全本地化
- 购买页面所有内容支持多语言
- 配件槽位名称、配件名称、描述完全本地化
- 修复了语言键缺失导致的警告问题
- 本地化改进**
- 配件改装GUI完全支持多语言切换
- 配件槽位选择界面支持多语言
- 配件效果描述支持多语言
- 所有错误消息和提示信息完全本地化
#### English
- Complete Multi-Language Support**
- All GUI interfaces fully support Chinese and English
- Attachment system interface fully localized
- All content in the purchase page supports multiple languages
- Attachment slot names, attachment names, and descriptions fully localized
- Fixed language key missing warnings
- Localization Improvements**
- Attachment modification GUI fully supports language switching
- Attachment slot selection interface supports multiple languages
- Attachment effect descriptions support multiple languages
- All error messages and prompts fully localized
### 配件系统全面重构 / Complete Attachment System Overhaul
#### 中文
- 移除旧升级系统,引入全新配件系统**
- 删除了原有的枪械升级系统(弹容量、射速、换弹时间等升级)
- 全新的配件改装系统,更加灵活和真实
- 配件系统核心特点**
- 5个配件槽位**:枪口、枪托、弹匣、侧导轨、下导轨
- 配件类型丰富**:
- 消音器(一级/二级):降低枪声,减少后坐力
- 补偿器(一级/二级):减少后坐力
- 扩容弹匣(一级/二级):增加弹匣容量,提升换弹速度
- 镭指:减少子弹散步
- 垂直握把:减少后坐力
- 枪托(一级/二级):减少后坐力
- 托腮板:减少10%后坐力(适用于霰弹枪、狙击枪、狙击步枪)
- 配件效果叠加**:
- 弹匣容量加成:最高可增加40%
- 换弹速度加成:最高可增加15%
- 枪声减少:最高可降低85%
- 后坐力减少:多种配件可叠加,最高可减少30%+
- 子弹散步减少:最高可减少20%
- 智能槽位系统**:
- 不同枪械类型支持不同的配件槽位组合
- 步枪、Vector、狙击步枪:支持全部5个槽位
- 手枪(P250、沙漠之鹰、USP、AA12):支持弹匣、枪口、下导轨、枪托
- CZ75:支持弹匣、枪口、下导轨
- S686:仅支持枪托
- 狙击枪:支持枪口、枪托
- PP19:仅支持枪口
- 机枪:支持弹匣、枪口
- 配件兼容性系统**:
- 狙击步枪(MK14、SKS)支持步枪配件和狙击枪配件
- 机枪(NEGEV)和AA12支持步枪弹匣
- 托腮板适用于霰弹枪、狙击枪、狙击步枪
- 智能配件分类:步枪配件、冲锋枪配件、霰弹枪配件、手枪配件、狙击枪配件
- 配件GUI系统**:
- 直观的配件改装界面
- 主界面显示所有可用槽位
- 槽位页面显示已安装配件和可用配件
- 配件效果实时显示
- 支持配件安装和卸载
- 配件数据持久化保存
#### English
- Removed Old Upgrade System, Introduced New Attachment System**
- Removed the old gun upgrade system (magazine size, fire rate, reload time upgrades)
- Brand new attachment modification system, more flexible and realistic
- Attachment System Core Features**
- 5 Attachment Slots**: Muzzle, Stock, Magazine, Side Rail, Under Rail
- Rich Attachment Types**:
- Silencers (Level 1/2): Reduce sound, reduce recoil
- Compensators (Level 1/2): Reduce recoil
- Extended Magazines (Level 1/2): Increase magazine capacity, improve reload speed
- Laser Sights: Reduce bullet spread
- Vertical Grips: Reduce recoil
- Stocks (Level 1/2): Reduce recoil
- Cheek Pads: Reduce 10% recoil (for shotguns, sniper rifles, and DMRs)
- Attachment Effect Stacking**:
- Magazine Capacity Bonus: Up to 40% increase
- Reload Speed Bonus: Up to 15% increase
- Sound Reduction: Up to 85% reduction
- Recoil Reduction: Multiple attachments can stack, up to 30%+ reduction
- Bullet Spread Reduction: Up to 20% reduction
- Smart Slot System**:
- Different gun types support different attachment slot combinations
- Rifles, Vector, DMRs: Support all 5 slots
- Pistols (P250, Desert Eagle, USP, AA12): Support Magazine, Muzzle, Under Rail, Stock
- CZ75: Support Magazine, Muzzle, Under Rail
- S686: Only supports Stock
- Sniper Rifles: Support Muzzle, Stock
- PP19: Only supports Muzzle
- LMG: Support Magazine, Muzzle
- Attachment Compatibility System**:
- DMRs (MK14, SKS) support rifle attachments and sniper attachments
- LMG (NEGEV) and AA12 support rifle magazines
- Cheek pads work with shotguns, sniper rifles, and DMRs
- Smart attachment categories: Rifle, SMG, Shotgun, Pistol, Sniper attachments
- Attachment GUI System**:
- Intuitive attachment modification interface
- Main interface shows all available slots
- Slot page shows installed and available attachments
- Real-time attachment effect display
- Support for attachment installation and removal
- Attachment data persistence
### 新增枪械 / New Gun
#### 中文
- USP手枪**
- 射速:352 RPM(半自动)
- 弹容量:12发
- 伤害:6.7
- 子弹速度:134米/秒
- 换弹时间:2.2秒
- 散步:小
- 材质:粉红色染料
- 价格:1200金币
- 支持配件:弹匣、枪口、下导轨、枪托
- 新增弹药类型**
- .45口径弹药
- 适用于USP手枪
- 材质:下界砖
- 价格:4320金币/组
#### English
- USP Pistol**
- Fire Rate: 352 RPM (Semi-automatic)
- Magazine: 12 rounds
- Damage: 6.7
- Bullet Speed: 134 m/s
- Reload Time: 2.2 seconds
- Spread: Small
- Material: Pink Dye
- Price: 1200 coins
- Supported Attachments: Magazine, Muzzle, Under Rail, Stock
- New Ammo Type**
- .45 Caliber Ammo
- For USP pistol
- Material: Nether Brick
- Price: 4320 coins/stack
### 音效系统增强 / Enhanced Sound System
#### 中文
- 丰富的开枪音效**
- AK74:
entity.zombie.break_wooden_door+block.comparator.click - HK416:
entity.zombie.attack_wooden_door+entity.zombie.attack_iron_door - AA12:
block.lever.click+entity.zombie.attack_wooden_door - S686:
entity.generic.explode+entity.zombie.attack_wooden_door+block.lever.click - PP19:
entity.zombie.attack_iron_door+block.comparator.click+item.trident.throw - Vector:
item.wolf_armor.damage+entity.zombie.attack_wooden_door - CZ75:
entity.zombie.attack_wooden_door+item.trident.throw - P250:
item.trident.throw+block.comparator.click - AUG:
item.trident.throw+entity.zombie.attack_wooden_door - NEGEV:
entity.dolphin.attack+entity.zombie.attack_iron_door - SKS:自定义音效组合
- 狙击枪(AWM、KAR98K):
entity.generic.explode+entity.warden.sonic_boom,发射后0.7秒播放三次item.armor.unequip_wolf
- 消音器音效**
- 当枪械装配消音器时,开枪音效自动切换为
item.wolf_armor.damage - 支持所有可安装消音器的枪械
#### English
- Rich Shooting Sound Effects**
- AK74:
entity.zombie.break_wooden_door+block.comparator.click - HK416:
entity.zombie.attack_wooden_door+entity.zombie.attack_iron_door - AA12:
block.lever.click+entity.zombie.attack_wooden_door - S686:
entity.generic.explode+entity.zombie.attack_wooden_door+block.lever.click - PP19:
entity.zombie.attack_iron_door+block.comparator.click+item.trident.throw - Vector:
item.wolf_armor.damage+entity.zombie.attack_wooden_door - CZ75:
entity.zombie.attack_wooden_door+item.trident.throw - P250:
item.trident.throw+block.comparator.click - AUG:
item.trident.throw+entity.zombie.attack_wooden_door - NEGEV:
entity.dolphin.attack+entity.zombie.attack_iron_door - SKS: Custom sound combination
- Sniper Rifles (AWM, KAR98K):
entity.generic.explode+entity.warden.sonic_boom, plays threeitem.armor.unequip_wolfsounds after 0.7 seconds
- Silencer Sound Effects**
- When a gun is equipped with a silencer, shooting sound automatically switches to
item.wolf_armor.damage - Supports all guns that can install silencers
### 枪械数值调整 / Gun Value Adjustments
#### 中文
- 射速系统重构**
- 射速单位从"射击间隔(秒)"改为"RPM(每分钟发射数)"
- 更直观的射速显示
- 精确的射速控制,支持快速射击(fireRate < 0.1)
- 射速调整**
- P250:400 RPM
- TEC9:500 RPM
- CZ75:600 RPM
- 沙漠之鹰:277 RPM(4.6发/秒)
- AK74:600 RPM
- AUG:630 RPM
- PP19:630 RPM
- Vector:1000 RPM
- NEGEV:583 RPM
- MK14:550 RPM
- SKS:600 RPM
- HK416:620 RPM
- AA12:462 RPM
- S686:600 RPM
#### English
- Fire Rate System Overhaul**
- Fire rate unit changed from "Shooting Interval (seconds)" to "RPM (Rounds Per Minute)"
- More intuitive fire rate display
- Precise fire rate control, supports fast shooting (fireRate < 0.1)
- Fire Rate Adjustments**
- P250: 400 RPM
- TEC9: 500 RPM
- CZ75: 600 RPM
- Desert Eagle: 277 RPM (4.6 rounds/second)
- AK74: 600 RPM
- AUG: 630 RPM
- PP19: 630 RPM
- Vector: 1000 RPM
- NEGEV: 583 RPM
- MK14: 550 RPM
- SKS: 600 RPM
- HK416: 620 RPM
- AA12: 462 RPM
- S686: 600 RPM
## 🔧 功能改进 / Feature Improvements
### 半自动射击模式优化 / Semi-Automatic Firing Mode Optimization
#### 中文
- 重写半自动射击逻辑**
- 按下右键发射一颗子弹
- 必须释放右键后再次按下才能发射下一发
- 更真实的半自动射击体验
- 修复了连续点击无法发射的问题
#### English
- Rewritten Semi-Automatic Firing Logic**
- Press right-click to fire one bullet
- Must release right-click and press again to fire the next shot
- More realistic semi-automatic firing experience
- Fixed issue where continuous clicking couldn't fire
### 配件系统优化 / Attachment System Optimization
#### 中文
- 配件GUI锁定**
- 配件GUI中的物品完全锁定,无法拖拽
- 防止误操作导致配件丢失
- 返回按钮和关闭按钮正常工作
- 配件兼容性优化**
- 智能配件兼容性检查
- 支持跨类型配件使用(如狙击步枪使用步枪配件)
- 配件效果正确叠加
#### English
- Attachment GUI Locking**
- Items in attachment GUI are completely locked, cannot be dragged
- Prevents accidental loss of attachments
- Back button and close button work correctly
- Attachment Compatibility Optimization**
- Smart attachment compatibility checking
- Supports cross-type attachment usage (e.g., DMRs using rifle attachments)
- Attachment effects correctly stack
## 🐛 错误修复 / Bug Fixes
### 配件系统修复 / Attachment System Fixes
#### 中文
- 修复了配件GUI中物品可以被拖拽的问题
- 修复了配件安装和卸载功能不工作的问题
- 修复了返回按钮无效的问题
- 修复了狙击步枪无法装配托腮板的问题
- 修复了配件页面部分内容未适配英文的问题
- 修复了狙击枪配件分类中重复显示托腮板的问题
#### English
- Fixed issue where items in attachment GUI could be dragged
- Fixed issue where attachment installation and removal didn't work
- Fixed issue where back button was ineffective
- Fixed issue where DMRs couldn't install cheek pads
- Fixed issue where part of attachment page wasn't adapted to English
- Fixed issue where sniper attachment category showed duplicate cheek pads
### 射击系统修复 / Firing System Fixes
#### 中文
- 修复了半自动武器连续点击无法发射的问题
- 修复了射速计算问题(fireRate < 0.1时射速过快)
- 修复了自动武器射速不准确的问题
#### English
- Fixed issue where semi-automatic weapons couldn't fire on continuous clicks
- Fixed fire rate calculation issue (fire rate too fast when fireRate < 0.1)
- Fixed issue where automatic weapon fire rate was inaccurate
### 语言系统修复 / Language System Fixes
#### 中文
- 修复了
command.unknown_command和command.reload_success语言键缺失的警告 - 修复了配件槽位名称未本地化的问题
- 修复了配件GUI标题未本地化的问题
#### English
- Fixed warnings for missing language keys
command.unknown_commandandcommand.reload_success - Fixed issue where attachment slot names weren't localized
- Fixed issue where attachment GUI titles weren't localized
## 📋 配置更新 / Configuration Updates
### 配置文件版本 / Configuration File Version
#### 中文
- 配置文件版本更新至
3.0.0 - 新增配件价格配置
- 新增USP和.45弹药价格配置
#### English
- Configuration file version updated to
3.0.0 - Added attachment price configuration
- Added USP and .45 ammo price configuration
### 配件价格配置 / Attachment Price Configuration
#### 中文
- 步枪配件:消音器、补偿器、扩容弹匣、镭指、握把、枪托
- 冲锋枪配件:消音器、扩容弹匣、握把、枪托
- 霰弹枪配件:消音器、枪托、托腮板
- 手枪配件:消音器、扩容弹匣、握把、枪托
- 狙击枪配件:消音器、补偿器、扩容弹匣、镭指、枪托、托腮板
#### English
- Rifle Attachments: Silencers, Compensators, Extended Magazines, Laser Sights, Grips, Stocks
- SMG Attachments: Silencers, Extended Magazines, Grips, Stocks
- Shotgun Attachments: Silencers, Stocks, Cheek Pads
- Pistol Attachments: Silencers, Extended Magazines, Grips, Stocks
- Sniper Attachments: Silencers, Compensators, Extended Magazines, Laser Sights, Stocks, Cheek Pads
## 🔄 技术改进 / Technical Improvements
### 代码结构优化 / Code Structure Optimization
#### 中文
- 新增
ModificationManager类管理配件系统 - 新增
ModificationGUI类处理配件GUI - 新增
AttachmentSlot和AttachmentType枚举 - 优化
GunType枚举,添加槽位支持方法 - 优化射速计算逻辑,使用毫秒级精确控制
#### English
- Added
ModificationManagerclass to manage attachment system - Added
ModificationGUIclass to handle attachment GUI - Added
AttachmentSlotandAttachmentTypeenums - Optimized
GunTypeenum, added slot support methods - Optimized fire rate calculation logic, using millisecond-level precision control
### 性能优化 / Performance Optimization
#### 中文
- 配件数据持久化优化
- GUI响应速度优化
- 射速计算性能优化
#### English
- Attachment data persistence optimization
- GUI response speed optimization
- Fire rate calculation performance optimization
## 🎯 兼容性 / Compatibility
### 向后兼容 / Backward Compatibility
#### 中文
- 保持原有枪械系统完全兼容
- 保持原有命令系统完全兼容
- 配置文件自动更新并保留自定义配置
#### English
- Maintains full compatibility with existing gun system
- Maintains full compatibility with existing command system
- Configuration files automatically update and preserve custom settings
### 版本兼容 / Version Compatibility
#### 中文
- 支持 Minecraft 1.21.4
- 支持 Spigot API
- 支持 Bukkit API
#### English
- Supports Minecraft 1.21.4
- Supports Spigot API
- Supports Bukkit API
## 📊 统计信息 / Statistics
### 代码统计 / Code Statistics
#### 中文
- 新增代码行数:约 1500+ 行
- 新增类文件:3个
- 修改文件:20+ 个
#### English
- New code lines: ~1500+ lines
- New class files: 3
- Modified files: 20+
### 功能统计 / Feature Statistics
#### 中文
- 新增配件类型:30+ 种
- 新增配件槽位:5个
- 新增枪械:1种(USP)
- 新增弹药类型:1种(.45口径)
- 新增音效组合:10+ 种
#### English
- New attachment types: 30+ types
- New attachment slots: 5
- New guns: 1 (USP)
- New ammo types: 1 (.45 Caliber)
- New sound combinations: 10+ types
## 📝 升级指南 / Upgrade Guide
### 从 2.0.0 升级到 3.0.0 / Upgrading from 2.0.0 to 3.0.0
#### 中文
1. **备份数据**
- 备份
plugins/GunPlugin/目录 - 备份玩家数据(如果有)
2. **更新插件**
- 下载
GunPlugin-3.0.0.jar - 替换旧版本插件文件
3. **更新配置**
- 配置文件会自动更新到 3.0.0 版本
- 自定义配置会被保留
- 检查新配置项并根据需要调整
4. **注意事项**
- 旧的升级系统已被移除,改为配件系统
- 玩家原有的升级数据不会自动转换
- 建议通知玩家重新配置配件
#### English
1. **Backup Data**
- Backup
plugins/GunPlugin/directory - Backup player data (if any)
2. **Update Plugin**
- Download
GunPlugin-3.0.0.jar - Replace old version plugin file
3. **Update Configuration**
- Configuration files will automatically update to version 3.0.0
- Custom settings will be preserved
- Check new configuration items and adjust as needed
4. **Important Notes**
- Old upgrade system has been removed, replaced with attachment system
- Player's existing upgrade data will not be automatically converted
- Recommend notifying players to reconfigure attachments
## 🙏 致谢 / Acknowledgments
#### 中文
- 主要开发者**:114514h
- 社区贡献者**:感谢所有贡献者
#### English
- Main Developer**: 114514h
- Community Contributors**: Thanks to all contributors
- 版本 3.0.0 - 2025年11月 / Version 3.0.0 - 11 2025**
## [2.0.1]
Updated bStats **更新了bStats**
## [2.0.0]
Updated a lot of content **更新了非常多的内容**
### 🎯 Major Updates 🎯 **主要更新**
- Added recoil system **添加了后坐力系统**
- Designed individual recoil for each firearm
- 为每个枪械设计了单独的后坐力**
- Added firearm purchase system **添加了枪械购买系统**
- You can customize the price of each firearm **可以自定义每个枪械的价格**
- Added firearm upgrade system **添加了枪械升级系统**
- Support players to upgrade multiple abilities of firearms **支持玩家为枪械的多项能力进行升级**
### 🔧 Feature Improvements 🔧 **功能改进**
- Improved smoke material **改进了烟雾弹材质**
- Improved the 'give' command **改进了give命令**
- Improved the stacking logic of firearms **改进了枪械堆叠逻辑**
### 🎮 New Commands 🎮 **新命令**
/gun buy- **枪械购买命令**/gun buy- **gun purchase command**/gun upgrade- **升级枪械命令**/Gun upgrade- **Command to upgrade firearms**
### 🐛 Bug Fixes 🐛 **错误修复**
- Fixed many bugs! **修复了很多漏洞!**
## [1.2.0]
### 🎯 Major Updates
#### Grenade System
- Added High Explosive Grenade**
- Explodes after 5 seconds, dealing damage to entities within 5 block radius
- Center explosion damage: 20 points, edge damage: 2 points
- Material: Slime Ball
- Supports left-click low throw and right-click high throw
- Added Molotov Cocktail**
- Generates fire particles in 3 block radius at impact point
- Deals 4 damage per second to players in contact, lasts 10 seconds
- Fire spreads downward until hitting non-air blocks
- Material: Fire Charge
- Supports left-click low throw and right-click high throw
- Added Smoke Grenade**
- Generates smoke particles in 3x3x3 area at impact point
- Provides visual cover, lasts 15 seconds
- Material: Egg
- Supports left-click low throw and right-click high throw
#### Multi-Language System
- Complete Multi-Language Support**
- Supports Chinese (zh_CN) and English (en_US)
- Language switching via configuration file
- Language switching command
/gun lang
- Localized Content**
- All in-game messages support multiple languages
- Gun names, ammo names, grenade names localized
- Help information, error messages, console logs localized
- ActionBar messages, item descriptions localized
### 🔧 Feature Improvements
#### Grenade System Optimization
- Throw Cooldown Mechanism**
- 2-second throw interval to prevent spam
- Shows remaining time during cooldown
- High Explosive Grenade Optimization**
- Countdown starts when thrown, not when landing
- Landing sound effects:
minecraft:block.anvil.placeandminecraft:entity.tnt.primed - Continuous smoke particles during countdown
- Ensures entity cleanup after explosion
- Molotov Cocktail Optimization**
- Fire sound effect
minecraft:block.fire.ambientin flames - Optimized downward fire spread logic
- Maximum 20 block depth check
- Smoke Grenade Optimization**
- Uses
minecraft:explosion_emitterparticle effect - Optimized smoke height and radius
#### Language System Optimization
- Language Manager Enhancement**
- Automatically copies language files from resources folder
- Supports message key fallback mechanism
- Detailed debug logs and error handling
- Parameter replacement system support
- Enum Multi-Language Support**
GunTypeenum supports localized namesAmmoTypeenum supports localized names and descriptions- Dynamic current language setting retrieval
### 🎮 New Commands
#### Language Management Commands
/gun lang- Show current language and available languages/gun lang <language_code>- Switch language (zh_CN/en_US)
#### Grenade Commands
/gun give grenade [amount]- Get High Explosive Grenade/gun give molotov [amount]- Get Molotov Cocktail/gun give smoke [amount]- Get Smoke Grenade
### 📋 Configuration Updates
#### Language Configuration
``
yaml
# Language Settings
# Supported languages: zh_CN (Chinese), en_US (English)
language: "zh_CN"
`
#### Grenade Configuration
- Throw distance: High throw max 50 blocks, low throw max 10 blocks
- Throw cooldown: 2 seconds
- Explosion delay: 5 seconds
- Fire duration: 10 seconds
- Smoke duration: 15 seconds
### 🐛 Bug Fixes
#### Grenade System Fixes
- Fixed bug where items were consumed during cooldown
- Fixed High Explosive Grenade explosion center position error
- Fixed grenade entity not being cleared after explosion
- Fixed inaccurate countdown timing
#### Multi-Language System Fixes
- Fixed warnings caused by missing message keys
- Fixed gun item names not being translated
- Fixed ActionBar messages not being translated
- Fixed console logs not being translated
- Fixed help messages not being translated
### 📁 New Files
#### Language Files
src/main/resources/messages/zh_CN.yml - Chinese language filesrc/main/resources/messages/en_US.yml - English language file
#### Documentation Files
- Multi-language system usage guide
- Multi-language system fix guide
- Final fix guide
- Grenade system usage guide
### 🔄 Technical Improvements
#### Code Structure Optimization
- Added
LanguageManager class for multi-language managementAdded GrenadeManager class for grenade managementAdded Grenade class for grenade logicOptimized GunCommand class for multi-language supportOptimized GunListener class for multi-language support
#### Performance Optimization
- Optimized grenade entity management
- Optimized language file loading
- Optimized message retrieval performance
### 🎯 Compatibility
#### Backward Compatibility
- Maintains complete compatibility with existing gun system
- Maintains complete compatibility with existing command system
- Maintains complete compatibility with existing configuration format
#### Version Compatibility
- Supports Minecraft 1.21.4
- Supports Spigot API
- Supports Bukkit API
### 📊 Statistics
#### Code Statistics
- New code lines: ~2000+ lines
- New class files: 4
- New language files: 2
- Modified files: 15+
#### Feature Statistics
- New grenade types: 3
- New language support: 2
- New commands: 3
- New configuration options: 1
# 枪械插件更新日志
## [1.2.0]
### 🎯 重大更新
#### 投掷物系统
- 新增高爆手雷**
- 投掷后5秒爆炸,对半径5格内的生物造成伤害
- 中心爆炸伤害20点,边缘伤害2点
- 材质:粘液球
- 支持左键低抛、右键高抛投掷
- 新增燃烧瓶**
- 在落点生成半径3格的火焰粒子
- 对接触的玩家造成每秒4点伤害,持续10秒
- 火焰会向下传播直到遇到非空气方块
- 材质:火焰弹
- 支持左键低抛、右键高抛投掷
- 新增烟雾弹**
- 在落点生成半径3格、高3格的烟雾粒子
- 提供视觉掩护,持续15秒
- 材质:鸡蛋
- 支持左键低抛、右键高抛投掷
#### 多语言系统
- 完整的多语言支持**
- 支持中文 (zh_CN) 和英文 (en_US)
- 可通过配置文件切换语言
- 支持语言切换命令
/gun lang
- 本地化内容**
- 所有游戏内消息支持多语言
- 枪械名称、弹药名称、投掷物名称本地化
- 帮助信息、错误消息、控制台日志本地化
- ActionBar消息、物品描述本地化
### 🔧 功能改进
#### 投掷物系统优化
- 投掷冷却机制**
- 投掷间隔2秒,防止连续投掷
- 冷却期间显示剩余时间提示
- 高爆手雷优化**
- 投掷时开始倒计时,不再等待落地
- 落地时播放音效:
minecraft:block.anvil.place 和 minecraft:entity.tnt.primed倒计时期间持续显示烟雾粒子 爆炸后确保实体正确清除
- 燃烧瓶优化**
- 火焰中播放火焰音效
minecraft:block.fire.ambient火焰向下传播逻辑优化 最多检查20格深度
- 烟雾弹优化**
- 使用
minecraft:explosion_emitter 粒子效果烟雾高度和半径优化
#### 语言系统优化
- 语言管理器增强**
- 自动从资源文件夹复制语言文件
- 支持消息键回退机制
- 详细的调试日志和错误处理
- 参数替换系统支持
- 枚举多语言支持**
GunType 枚举支持本地化名称AmmoType 枚举支持本地化名称和描述动态获取当前语言设置
### 🎮 新增命令
#### 语言管理命令
/gun lang - 显示当前语言和可用语言/gun lang <语言代码> - 切换语言 (zh_CN/en_US)
#### 投掷物命令
/gun give grenade [数量] - 获得高爆手雷/gun give molotov [数量] - 获得燃烧瓶/gun give smoke [数量] - 获得烟雾弹
### 📋 配置更新
#### 语言配置
`yaml
# 语言设置 (Language Settings)
# 支持的语言: zh_CN (中文), en_US (英文)
language: "zh_CN"
`
#### 投掷物配置
- 投掷距离:高抛最远50格,低抛最远10格
- 投掷冷却:2秒
- 爆炸延迟:5秒
- 火焰持续时间:10秒
- 烟雾持续时间:15秒
### 🐛 错误修复
#### 投掷物系统修复
- 修复投掷冷却期间仍扣除物品数量的bug
- 修复高爆手雷爆炸中心位置错误的问题
- 修复手雷爆炸后实体不清除的问题
- 修复倒计时时间不准确的问题
#### 多语言系统修复
- 修复消息键不存在导致的警告
- 修复枪械物品名称不翻译的问题
- 修复ActionBar消息不翻译的问题
- 修复控制台日志不翻译的问题
- 修复帮助消息不翻译的问题
### 📁 新增文件
#### 语言文件
src/main/resources/messages/zh_CN.yml - 中文语言文件src/main/resources/messages/en_US.yml - 英文语言文件
#### 文档文件
多语言系统说明.md - 多语言系统使用说明多语言系统修复说明.md - 多语言系统修复说明多语言系统最终修复说明.md - 最终修复说明投掷物系统说明.md - 投掷物系统使用说明
### 🔄 技术改进
#### 代码结构优化
- 新增
LanguageManager 类管理多语言新增 GrenadeManager 类管理投掷物新增 Grenade 类处理投掷物逻辑优化 GunCommand 类支持多语言优化 GunListener` 类支持多语言#### 性能优化
- 投掷物实体管理优化
- 语言文件加载优化
- 消息获取性能优化
### 🎯 兼容性
#### 向后兼容
- 保持原有枪械系统完全兼容
- 保持原有命令系统完全兼容
- 保持原有配置文件格式兼容
#### 版本兼容
- 支持 Minecraft 1.21.4
- 支持 Spigot API
- 支持 Bukkit API
### 📊 统计信息
#### 代码统计
- 新增代码行数:约 2000+ 行
- 新增类文件:4个
- 新增语言文件:2个
- 修改文件:15+ 个
#### 功能统计
- 新增投掷物类型:3种
- 新增语言支持:2种
- 新增命令:3个
- 新增配置项:1个
- 版本**: 1.2.0
### 🆕 New Weapon System
- Renamed Original Weapons**:
- Pistol → P250 (Leather Horse Armor)
- Rifle → AK-74 (Iron Horse Armor)
- Shotgun → AA-12 (Golden Horse Armor)
- Sniper → AWM (Diamond Horse Armor)
- Added 11 New Weapons**:
- HK416 (Black Dye) - Full-auto assault rifle
- PP19 (Brown Dye) - High-rate submachine gun
- AUG (Red Dye) - Precision assault rifle
- MK-14 (Orange Dye) - High-damage automatic rifle
- S686 (Yellow Dye) - Double-barrel shotgun
- 98K (Lime Dye) - Classic sniper rifle
- Vector (Green Dye) - Ultra-high-speed submachine gun
- Negev (Cyan Dye) - Heavy machine gun
- SKS (Light Blue Dye) - Semi-automatic sniper rifle
- Desert Eagle (Blue Dye) - High-caliber pistol
- CZ75 (Purple Dye) - Compact pistol
### 🎯 Weapon Characteristics
- Firing Mode Classification**:
- Full-auto weapons: AK-74, HK416, PP19, AUG, MK-14, Vector, Negev, CZ75
- Semi-auto weapons: 98K, SKS, Desert Eagle
- Single-shot weapons: P250, AWM
- Shotguns: AA-12, S686
- Balanced Design**:
- Damage range: 4.0-20.0
- Fire rate range: 0.4-25 rounds/second
- Magazine capacity range: 2-150 rounds
- Penetration power: 0-4 blocks
### 🎵 Sound System
- Sound Classification**:
- Pistol sound group: P250, CZ75, Desert Eagle
- Rifle sound group: AK-74, HK416, PP19, AUG, MK-14, Vector, Negev, SKS
- Shotgun sound group: AA-12, S686
- Sniper sound group: AWM, 98K
- Multi-layered Sounds**:
- Each weapon has unique shooting sounds
- Includes main sound and delayed sound
- Volume and pitch carefully tuned
### 🔧 Command System
- New Command Support**:
- Supports
/gun givecommand for all 15 weapons - Complete auto-completion functionality
- Detailed help information
- Backward Compatibility**:
- Maintains full compatibility with old commands
pistol→ P250,rifle→ AK-74,shotgun→ AA-12,sniper→ AWM
### 📊 Technical Improvements
- Code Refactoring**:
- Updated GunType enum to support 15 weapons
- Refactored sound system with sound classification
- Optimized command processing logic
- Performance Optimization**:
- Improved weapon identification algorithms
- Optimized sound playback mechanisms
- Enhanced memory management
## v1.1.0 - 重大更新
### 🆕 新枪械系统 / New Weapon System
- 重命名原枪械** / **Renamed Original Weapons**:
- 手枪 → P250 (皮革马铠)
- 步枪 → AK-74 (铁马铠)
- 霰弹枪 → AA-12 (金马铠)
- 狙击枪 → AWM (钻石马铠)
- 新增11种枪械** / **Added 11 New Weapons**:
- HK416 (黑色染料) - 全自动突击步枪
- PP19 (棕色染料) - 高射速冲锋枪
- AUG (红色染料) - 精确突击步枪
- MK-14 (橙色染料) - 高伤害自动步枪
- S686 (黄色染料) - 双管霰弹枪
- 98K (黄绿色染料) - 经典狙击步枪
- Vector (绿色染料) - 超高速冲锋枪
- 内格夫 (青色染料) - 重型机枪
- SKS (淡蓝色染料) - 半自动狙击步枪
- 沙漠之鹰 (蓝色染料) - 大口径手枪
- CZ75 (紫色染料) - 紧凑型手枪
### 🎯 武器特性 / Weapon Characteristics
- 射击模式分类** / **Firing Mode Classification**:
- 全自动武器: AK-74, HK416, PP19, AUG, MK-14, Vector, 内格夫, CZ75
- 半自动武器: 98K, SKS, 沙漠之鹰
- 单发武器: P250, AWM
- 霰弹枪: AA-12, S686
- 平衡性设计** / **Balanced Design**:
- 伤害范围: 4.0-20.0
- 射速范围: 0.4-25发/秒
- 弹容量范围: 2-150发
- 穿透力: 0-4格
### 🎵 音效系统 / Sound System
- 音效分类** / **Sound Classification**:
- 手枪音效组: P250, CZ75, 沙漠之鹰
- 步枪音效组: AK-74, HK416, PP19, AUG, MK-14, Vector, 内格夫, SKS
- 霰弹枪音效组: AA-12, S686
- 狙击枪音效组: AWM, 98K
- 多层次音效** / **Multi-layered Sounds**:
- 每种枪械都有独特的射击音效
- 包含主音效和延迟音效
- 音量和音调经过精心调校
### 🔧 命令系统 / Command System
- 新命令支持** / **New Command Support**:
- 支持所有15种枪械的
/gun give命令 - 完整的自动补全功能
- 详细的帮助信息
- 向后兼容** / **Backward Compatibility**:
- 保持旧命令的完全兼容性
pistol→ P250,rifle→ AK-74,shotgun→ AA-12,sniper→ AWM
### 📊 技术改进 / Technical Improvements
- 代码重构** / **Code Refactoring**:
- 更新了GunType枚举,支持15种枪械
- 重构了音效系统,支持音效分类
- 优化了命令处理逻辑
- 性能优化** / **Performance Optimization**:
- 改进了枪械识别算法
- 优化了音效播放机制
- 增强了内存管理
### 🎵 音效调整 / Sound Adjustments
- CZ75音效更新** / **CZ75 Sound Update**:
- 从步枪音效改为手枪音效
- 与P250使用相同的音效配置
- 更符合其紧凑型手枪的定位
- 沙漠之鹰音效更新** / **Desert Eagle Sound Update**:
- 从步枪音效改为手枪音效
- 与P250使用相同的音效配置
- 更符合其大口径手枪的特点
### 🔧 技术实现 / Technical Implementation
- 添加了专门的音效处理逻辑
- 为CZ75和沙漠之鹰配置了与P250相同的手枪音效
- 保持了音效系统的一致性和可维护性
# GunPlugin - Detailed Plugin Description
## 📖 插件概述 / Plugin Overview
### 中文描述
GunPlugin是一个功能丰富的Minecraft枪械插件,为Spigot 1.21.4服务器提供完整的射击体验。插件支持多种枪械类型、真实弹道系统、自定义配置和高级射击功能,让玩家在Minecraft中体验真实的枪战。
### English Description
GunPlugin is a feature-rich Minecraft gun plugin that provides a complete shooting experience for Spigot 1.21.4 servers. The plugin supports multiple weapon types, realistic ballistics system, custom configuration, and advanced shooting features, allowing players to experience realistic gunfights in Minecraft.
## 🎯 功能列表 / Feature List
### 核心功能 / Core Features
#### 1. 枪械系统 / Weapon System
- 默认枪械** / **Default Weapons**:
- 手枪 (皮革马铠) - 单发,12发弹匣,4点伤害
- 步枪 (铁马铠) - 连发,40发弹匣,5点伤害
- 霰弹枪 (金马铠) - 多发,7发弹匣,15点伤害
- 狙击枪 (钻石马铠) - 单发,5发弹匣,20点伤害
- 自定义枪械** / **Custom Weapons**:
- 支持任意物品材质作为枪械
- 可配置弹匣容量、伤害、射速等参数
- 支持自动/单发/霰弹枪模式
#### 2. 弹道系统 / Ballistics System
- 子弹物理** / **Bullet Physics**:
- 真实的重力下坠效果
- 可配置的子弹速度
- 穿透系统(可穿透特定方块)
- 移动散步系统(移动时精度降低)
#### 3. 射击机制 / Shooting Mechanics
- 射击模式** / **Firing Modes**:
- 单发模式:点击射击
- 连发模式:按住连续射击
- 霰弹枪模式:一次发射多发子弹
- 弹药管理** / **Ammunition Management**:
- 弹匣系统
- 自动换弹
- 手动换弹(F键)
- 弹药显示(ActionBar)
#### 4. 音效系统 / Sound System
- 多层次音效** / **Multi-layered Sounds**:
- 射击音效(延迟播放)
- 换弹音效(分阶段播放)
- 击中音效
- 后坐力音效
#### 5. 视觉效果 / Visual Effects
- 粒子效果** / **Particle Effects**:
- 枪口火焰
- 子弹轨迹
- 击中效果
- 血雾效果
- 后坐力粒子
#### 6. 交互系统 / Interaction System
- 左键右键禁用** / **Left/Right Click Disable**:
- 持枪时禁用左键攻击
- 持枪时禁用右键交互
- 可配置开启/关闭
#### 7. 高级功能 / Advanced Features
- 爆头检测** / **Headshot Detection**:
- 击中头部增加30%伤害
- 特殊音效反馈
- 后坐力系统** / **Recoil System**:
- 视觉粒子反馈
- 不影响玩家移动
## 📚 使用教程 / Usage Tutorial
### 基础使用 / Basic Usage
#### 1. 获得枪械 / Getting Weapons
``
bash
# 给予默认枪械 / Give default weapons
/gun give pistol # 手枪 / Pistol
/gun give rifle # 步枪 / Rifle
/gun give shotgun # 霰弹枪 / Shotgun
/gun give sniper # 狙击枪 / Sniper
# 给予自定义枪械 / Give custom weapons
/gun give custom_rifle # 自定义步枪 / Custom rifle
`
#### 2. 射击操作 / Shooting Operations
- 单发武器** / **Single-shot Weapons**:
- 右键点击射击
- 自动消耗弹药
- 弹匣空时自动换弹
- 连发武器** / **Automatic Weapons**:
- 按住右键连续射击
- 松开右键停止射击
- 支持弹药耗尽自动换弹
- 霰弹枪** / **Shotgun**:
- 一次发射5发子弹
- 每发子弹有独立弹道
- 近距离伤害更高
#### 3. 换弹操作 / Reload Operations
- 自动换弹** / **Auto Reload**:
- 弹匣空时自动开始换弹
- 显示换弹进度
- 播放换弹音效
- 手动换弹** / **Manual Reload**:
- 按F键手动换弹
- 可在任何时候换弹
- 换弹时无法射击
#### 4. 弹药管理 / Ammunition Management
`bash
# 设置弹药数量 / Set ammo count
/gun ammo 100 # 设置当前枪械弹药为100发 / Set current weapon ammo to 100
# 查看弹药信息 / View ammo info
# 弹药信息显示在ActionBar中 / Ammo info displayed in ActionBar
`
### 高级使用 / Advanced Usage
#### 1. 自定义枪械创建 / Custom Weapon Creation
`yaml
# 在config.yml中添加自定义枪械 / Add custom weapon in config.yml
guns:
my_rifle:
name: "我的步枪" # Weapon name
material: "IRON_SWORD" # Item material
magazine_size: 30 # Magazine capacity
damage: 6.0 # Damage
fire_rate: 0.1 # Fire rate (seconds)
bullet_speed: 80 # Bullet speed
bullet_drop: 0.08 # Bullet drop
shoot_sound: "ENTITY_ZOMBIE_BREAK_WOODEN_DOOR" # Shoot sound
reload_time: 2.5 # Reload time
penetration_power: 2 # Penetration power
recoil: 1.8 # Recoil
is_automatic: true # Automatic firing
is_shotgun: false # Not shotgun
shotgun_pellets: 1 # Single pellet
`
#### 2. 配置系统设置 / Configure System Settings
`yaml
# 插件设置 / Plugin settings
settings:
disable_left_click: true # 禁用左键攻击 / Disable left-click attacks
disable_right_click_interaction: true # 禁用右键交互 / Disable right-click interactions
`
#### 3. 权限配置 / Permission Configuration
`yaml
# LuckPerms权限配置示例 / LuckPerms permission configuration example
groups:
default:
permissions:
- gunplugin.use # 基础使用权限 / Basic usage permission
vip:
permissions:
- gunplugin.use
- gunplugin.give # 给予枪械权限 / Give weapons permission
admin:
permissions:
- gunplugin.* # 所有权限 / All permissions
`
## 🔧 调试教程 / Debugging Tutorial
### 常见问题诊断 / Common Issue Diagnosis
#### 1. 子弹没有伤害 / Bullets Don't Deal Damage
- 症状** / **Symptoms**:
- 子弹击中目标但没有伤害
- 子弹轨迹正常但无效果
- 诊断步骤** / **Diagnosis Steps**:
`bash
# 1. 检查玩家权限 / Check player permissions
/lp user <player> permission check gunplugin.use
# 2. 检查插件状态 / Check plugin status
/plugins
# 3. 查看控制台错误 / Check console errors
# 查看服务器控制台是否有错误信息 / Check server console for error messages
# 4. 测试基础功能 / Test basic functions
/gun give pistol
# 尝试射击测试 / Try shooting test
`
- 解决方案** / **Solutions**:
- 确保玩家有
gunplugin.use权限检查插件是否正确加载 重新加载插件: /reload检查是否有其他插件冲突
#### 2. 自动射击不工作 / Auto Fire Not Working
- 症状** / **Symptoms**:
- 按住右键无法连续射击
- 射击立即停止
- 诊断步骤** / **Diagnosis Steps**:
`bash
# 1. 检查枪械类型 / Check weapon type
# 确认使用的是自动武器(步枪) / Confirm using automatic weapon (rifle)
# 2. 检查弹药 / Check ammunition
# 确保有足够弹药 / Ensure sufficient ammunition
# 3. 检查换弹状态 / Check reload status
# 确保不在换弹中 / Ensure not reloading
`
- 解决方案** / **Solutions**:
- 使用步枪进行测试
- 确保弹药充足
- 等待换弹完成
- 检查右键松开检测设置
#### 3. 自定义枪械不工作 / Custom Weapons Not Working
- 症状** / **Symptoms**:
- 自定义枪械无法射击
- 配置不生效
- 诊断步骤** / **Diagnosis Steps**:
`bash
# 1. 检查配置文件语法 / Check config file syntax
# 确保YAML格式正确 / Ensure YAML format is correct
# 2. 重新加载配置 / Reload configuration
/reload
# 3. 检查材质名称 / Check material names
# 确保材质名称正确 / Ensure material names are correct
`
- 解决方案** / **Solutions**:
- 检查YAML语法错误
- 使用正确的材质名称
- 重新加载插件
- 参考默认配置格式
#### 4. 音效不播放 / Sounds Not Playing
- 症状** / **Symptoms**:
- 射击时没有音效
- 换弹时没有音效
- 诊断步骤** / **Diagnosis Steps**:
`bash
# 1. 检查音效名称 / Check sound names
# 确保音效名称正确 / Ensure sound names are correct
# 2. 检查客户端设置 / Check client settings
# 确保音效已启用 / Ensure sounds are enabled
# 3. 测试默认音效 / Test default sounds
# 使用默认枪械测试 / Test with default weapons
`
- 解决方案** / **Solutions**:
- 使用正确的音效名称
- 检查客户端音效设置
- 使用默认配置测试
- 更新到最新版本
### 调试命令 / Debug Commands
`bash
# 检查插件状态 / Check plugin status
/plugins
# 重新加载插件 / Reload plugin
/reload
# 检查玩家权限 / Check player permissions
/lp user <player> permission check gunplugin.use
# 查看插件配置 / View plugin configuration
# 检查plugins/GunPlugin/config.yml文件 / Check plugins/GunPlugin/config.yml file
`
### 日志分析 / Log Analysis
#### 重要日志信息 / Important Log Information
`bash
# 插件加载日志 / Plugin loading logs
[INFO] [GunPlugin] Enabling GunPlugin v1.9.7
[INFO] [GunPlugin] GunPlugin has been enabled!
# 错误日志 / Error logs
[ERROR] [GunPlugin] Error in bullet update task
[WARN] [GunPlugin] Player not found in ammo data
# 调试信息 / Debug information
[DEBUG] [GunPlugin] Player <player> shot with <weapon>
[DEBUG] [GunPlugin] Bullet hit entity: <entity>
`
## ⚙️ 功能原理 / Feature Principles
### 1. 子弹系统原理 / Bullet System Principles
#### 子弹创建 / Bullet Creation
`java
// 子弹创建流程 / Bullet creation process
1. 玩家射击触发 / Player shooting triggered
2. 检查弹药和权限 / Check ammunition and permissions
3. 创建Bullet对象 / Create Bullet object
4. 添加到activeBullets列表 / Add to activeBullets list
5. 启动子弹更新任务 / Start bullet update task
`
#### 子弹更新 / Bullet Update
`java
// 子弹更新机制 / Bullet update mechanism
public boolean update() {
// 1. 应用重力 / Apply gravity
velocity.add(new Vector(0, -bulletDrop / 20.0, 0));
// 2. 移动子弹 / Move bullet
Location newLocation = location.clone().add(velocity);
// 3. 检测碰撞 / Detect collision
RayTraceResult result = world.rayTraceEntities(...);
// 4. 处理击中 / Handle hit
if (result != null) {
// 造成伤害 / Deal damage
// 播放音效 / Play sound
// 显示粒子 / Show particles
return true; // 移除子弹 / Remove bullet
}
// 5. 检查方块碰撞 / Check block collision
// 6. 处理穿透 / Handle penetration
// 7. 更新位置 / Update position
}
`
### 2. 射击系统原理 / Shooting System Principles
#### 单发射击 / Single Shot
`java
// 单发射击流程 / Single shot process
1. 检查射击条件 / Check shooting conditions
- 弹药检查 / Ammunition check
- 射速检查 / Fire rate check
- 权限检查 / Permission check
2. 创建子弹 / Create bullet
- 计算方向 / Calculate direction
- 应用散步 / Apply spread
- 设置参数 / Set parameters
3. 播放效果 / Play effects
- 音效 / Sound effects
- 粒子 / Particles
- 后坐力 / Recoil
4. 更新状态 / Update status
- 消耗弹药 / Consume ammunition
- 更新ActionBar / Update ActionBar
- 记录射击时间 / Record shot time
`
#### 连发射击 / Automatic Fire
`java
// 连发射击机制 / Automatic fire mechanism
1. 右键按下 / Right-click pressed
- 设置按住状态 / Set holding state
- 记录时间 / Record time
- 启动连发任务 / Start auto-fire task
2. 连发任务循环 / Auto-fire task loop
- 检查按住状态 / Check holding state
- 检查时间间隔 / Check time interval
- 检查弹药 / Check ammunition
- 发射子弹 / Fire bullet
3. 右键松开 / Right-click released
- 清除按住状态 / Clear holding state
- 停止连发任务 / Stop auto-fire task
`
### 3. 弹药系统原理 / Ammunition System Principles
#### 弹药存储 / Ammunition Storage
`java
// 弹药数据结构 / Ammunition data structure
Map<UUID, Map<GunType, Integer>> playerAmmo; // 默认枪械弹药 / Default weapon ammo
Map<UUID, Map<Material, Integer>> configGunAmmo; // 配置枪械弹药 / Config weapon ammo
// 弹药操作 / Ammunition operations
- getAmmo(player, weapon) // 获取弹药 / Get ammunition
- setAmmo(player, weapon, amount) // 设置弹药 / Set ammunition
- consumeAmmo(player, weapon) // 消耗弹药 / Consume ammunition
- reload(player, weapon) // 换弹 / Reload
`
#### 换弹机制 / Reload Mechanism
`java
// 换弹流程 / Reload process
1. 检查换弹条件 / Check reload conditions
- 是否在换弹中 / Is reloading
- 弹匣是否已满 / Is magazine full
2. 开始换弹 / Start reload
- 添加到换弹列表 / Add to reloading list
- 启动换弹任务 / Start reload task
- 播放换弹音效 / Play reload sounds
3. 换弹任务 / Reload task
- 等待换弹时间 / Wait for reload time
- 填充弹药 / Fill ammunition
- 完成换弹 / Complete reload
`
### 4. 音效系统原理 / Sound System Principles
#### 多层次音效 / Multi-layered Sounds
`java
// 射击音效系统 / Shoot sound system
switch (gunType) {
case PISTOL:
// 第一层音效 / First layer sound
player.playSound(loc, Sound.ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR, 0.7f, 1.9f);
// 延迟音效 / Delayed sound
new BukkitRunnable() {
public void run() {
player.playSound(loc, Sound.ITEM_TRIDENT_THROW, 0.7f, 1.3f);
}
}.runTaskLater(plugin, 1L); // 1 tick delay
break;
}
// 换弹音效系统 / Reload sound system
// 分阶段播放音效 / Play sounds in stages
- 第一阶段:换弹开始 / Stage 1: Reload start
- 第二阶段:换弹进行 / Stage 2: Reload in progress
- 第三阶段:换弹完成 / Stage 3: Reload complete
`
### 5. 粒子系统原理 / Particle System Principles
#### 粒子效果类型 / Particle Effect Types
`java
// 射击粒子 / Shoot particles
- 枪口火焰 / Muzzle flash
- 子弹轨迹 / Bullet trajectory
- 击中效果 / Hit effects
// 换弹粒子 / Reload particles
- 换弹进度 / Reload progress
- 完成效果 / Completion effects
// 后坐力粒子 / Recoil particles
- 烟雾效果 / Smoke effects
- 视觉反馈 / Visual feedback
`
### 6. 权限系统原理 / Permission System Principles
#### 权限检查 / Permission Checking
`java
// 权限检查流程 / Permission check process
1. 事件触发 / Event triggered
2. 检查基础权限 / Check basic permission
if (!player.hasPermission("gunplugin.use")) return;
3. 检查特定权限 / Check specific permission
if (!player.hasPermission("gunplugin.admin")) return;
4. 执行操作 / Execute operation
`
## 🎮 游戏机制 / Game Mechanics
### 1. 射击精度 / Shooting Accuracy
#### 散步系统 / Spread System
`java
// 散步计算 / Spread calculation
private double calculateSpread(Player player) {
// 1. 获取玩家移动距离 / Get player movement distance
double distance = currentLocation.distance(lastLocation);
// 2. 根据移动计算散步 / Calculate spread based on movement
if (distance < 0.1) {
return 0.05; // 静止时轻微散步 / Slight spread when stationary
} else if (distance < 0.5) {
return distance * 0.3; // 缓慢移动 / Slow movement
} else {
return Math.min(distance * 0.8, 1.2); // 快速移动 / Fast movement
}
}
`
#### 精度影响因素 / Accuracy Factors
- 移动速度** / **Movement Speed**: 移动越快,散步越大
- 武器类型** / **Weapon Type**: 不同武器有不同的基础精度
- 射击距离** / **Shooting Distance**: 距离越远,散步影响越大
### 2. 伤害系统 / Damage System
#### 基础伤害 / Base Damage
`java
// 伤害计算 / Damage calculation
double finalDamage = baseDamage;
// 爆头检测 / Headshot detection
if (isHeadshot(entity, hitPosition)) {
finalDamage *= 1.3; // 增加30%伤害 / Increase 30% damage
}
// 应用伤害 / Apply damage
entity.damage(finalDamage, shooter);
`
#### 伤害类型 / Damage Types
- 基础伤害** / **Base Damage**: 武器配置的伤害值
- 爆头伤害** / **Headshot Damage**: 击中头部增加30%伤害
- 穿透伤害** / **Penetration Damage**: 穿透后的伤害衰减
### 3. 弹道系统 / Ballistics System
#### 重力影响 / Gravity Effect
`java
// 重力计算 / Gravity calculation
velocity.add(new Vector(0, -bulletDrop / 20.0, 0));
// 弹道下坠 / Ballistic drop
- 手枪:较重下坠 / Pistol: Heavy drop
- 步枪:轻微下坠 / Rifle: Light drop
- 霰弹枪:较重下坠 / Shotgun: Heavy drop
- 狙击枪:轻微下坠 / Sniper: Light drop
`
#### 穿透系统 / Penetration System
`java
// 穿透检查 / Penetration check
private boolean canPenetrateBlock(Material material) {
// 可穿透方块 / Penetrable blocks
- 草类方块 / Grass blocks
- 花类方块 / Flower blocks
- 玻璃类方块 / Glass blocks
- 空气 / Air
// 根据穿透力判断 / Judge by penetration power
- 步枪:1格穿透 / Rifle: 1 block penetration
- 狙击枪:4格穿透 / Sniper: 4 block penetration
}
`
## 🔍 技术架构 / Technical Architecture
### 1. 类结构 / Class Structure
`
GunPlugin (主类 / Main Class)
├── GunManager (枪械管理器 / Gun Manager)
├── GunListener (事件监听器 / Event Listener)
├── GunCommand (命令处理器 / Command Handler)
├── ConfigManager (配置管理器 / Config Manager)
├── AmmoData (弹药数据 / Ammunition Data)
├── Bullet (子弹类 / Bullet Class)
└── GunType (枪械类型枚举 / Gun Type Enum)
`
### 2. 数据流 / Data Flow
`
玩家操作 / Player Action
↓
事件监听 / Event Listening
↓
权限检查 / Permission Check
↓
枪械识别 / Weapon Identification
↓
射击处理 / Shooting Process
↓
子弹创建 / Bullet Creation
↓
碰撞检测 / Collision Detection
↓
伤害应用 / Damage Application
↓
效果播放 / Effect Playback
`
### 3. 任务调度 / Task Scheduling
`java
// 主要任务 / Main tasks
- 子弹更新任务 / Bullet update task (每tick / Every tick)
- 右键检测任务 / Right-click detection task (每tick / Every tick)
- ActionBar更新任务 / ActionBar update task (每2秒 / Every 2 seconds)
- 换弹任务 / Reload task (延迟执行 / Delayed execution)
- 音效任务 / Sound task (延迟执行 / Delayed execution)
`
## 📊 性能优化 / Performance Optimization
### 1. 内存管理 / Memory Management
#### 子弹生命周期 / Bullet Lifecycle
`java
// 子弹自动清理 / Automatic bullet cleanup
- 最大存活时间:100 ticks (5秒) / Max lifetime: 100 ticks (5 seconds)
- 击中后立即移除 / Remove immediately after hit
- 定期清理过期子弹 / Regular cleanup of expired bullets
`
#### 数据清理 / Data Cleanup
`java
// 玩家数据清理 / Player data cleanup
- 玩家退出时清理 / Cleanup on player quit
- 定期清理离线玩家数据 / Regular cleanup of offline player data
- 内存泄漏防护 / Memory leak prevention
`
### 2. 性能监控 / Performance Monitoring
#### 关键指标 / Key Metrics
- 活跃子弹数量** / **Active Bullet Count**: 监控内存使用
- 玩家数量** / **Player Count**: 监控数据存储
- 任务执行时间** / **Task Execution Time**: 监控性能影响
#### 优化策略 / Optimization Strategies
- 批量处理** / **Batch Processing**: 批量更新子弹状态
- 延迟加载** / **Lazy Loading**: 按需加载配置数据
- 缓存机制** / **Caching**: 缓存常用数据
## 🛡️ 安全考虑 / Security Considerations
### 1. 权限控制 / Permission Control
#### 权限分级 / Permission Levels
`java
// 权限等级 / Permission levels
- gunplugin.use: 基础使用权限 / Basic usage permission
- gunplugin.admin: 管理员权限 / Admin permission
- gunplugin.give: 给予枪械权限 / Give weapons permission
- gunplugin.ammo: 设置弹药权限 / Set ammo permission
`
#### 安全检查 / Security Checks
- 权限验证** / **Permission Verification**: 每次操作前检查权限
- 输入验证** / **Input Validation**: 验证命令参数
- 数据验证** / **Data Validation**: 验证配置文件数据
### 2. 防作弊 / Anti-Cheat
#### 射击限制 / Shooting Restrictions
- 射速限制** / **Fire Rate Limitation**: 防止快速射击
- 弹药检查** / **Ammunition Check**: 防止无限弹药
- 距离检查** / **Distance Check**: 防止超远距离射击
#### 数据完整性 / Data Integrity
- 状态同步** / **State Synchronization**: 确保客户端服务器状态一致
- 异常检测** / **Anomaly Detection**: 检测异常行为
- 日志记录** / **Logging**: 记录可疑活动
## 📈 扩展性 / Extensibility
### 1. 插件API / Plugin API
#### 事件系统 / Event System
`java
// 自定义事件 / Custom events
- GunShootEvent: 射击事件 / Shooting event
- GunReloadEvent: 换弹事件 / Reload event
- BulletHitEvent: 子弹击中事件 / Bullet hit event
`
#### 钩子接口 / Hook Interfaces
`java
// 可扩展接口 / Extensible interfaces
- WeaponProvider: 武器提供者 / Weapon provider
- DamageCalculator: 伤害计算器 / Damage calculator
- EffectRenderer: 效果渲染器 / Effect renderer
`
### 2. 配置扩展 / Configuration Extension
#### 动态配置 / Dynamic Configuration
- 热重载** / **Hot Reload**: 无需重启服务器
- 条件配置** / **Conditional Configuration**: 基于条件的配置
- 模板系统** / **Template System**: 配置模板支持
#### 多语言支持 / Multi-language Support
- 本地化** / **Localization**: 支持多种语言
- 动态切换** / **Dynamic Switching**: 运行时切换语言
- 自定义翻译** / **Custom Translation**: 自定义翻译文件
## 🎯 最佳实践 / Best Practices
### 1. 服务器配置 / Server Configuration
#### 推荐设置 / Recommended Settings
`yaml
# 服务器配置建议 / Server configuration recommendations
server.properties:
view-distance: 10 # 视距设置 / View distance setting
simulation-distance: 8 # 模拟距离 / Simulation distance
# 插件配置建议 / Plugin configuration recommendations
config.yml:
settings:
disable_left_click: true # 禁用左键攻击 / Disable left-click attacks
disable_right_click_interaction: true # 禁用右键交互 / Disable right-click interactions
``#### 性能优化 / Performance Optimization
- 限制玩家数量** / **Limit Player Count**: 避免过多玩家同时使用
- 定期重启** / **Regular Restart**: 定期重启服务器清理内存
- 监控资源** / **Monitor Resources**: 监控CPU和内存使用
### 2. 游戏平衡 / Game Balance
#### 武器平衡 / Weapon Balance
- 伤害调整** / **Damage Adjustment**: 根据服务器需求调整伤害
- 射速限制** / **Fire Rate Limitation**: 防止武器过于强大
- 弹药限制** / **Ammunition Limitation**: 控制弹药获取
#### 经济系统 / Economy System
- 武器价格** / **Weapon Prices**: 设置合理的武器价格
- 弹药消耗** / **Ammunition Consumption**: 控制弹药消耗
- 维护成本** / **Maintenance Cost**: 武器维护成本
## 🔮 未来规划 / Future Plans
### 1. 功能扩展 / Feature Extensions
#### 计划功能 / Planned Features
- 武器改装系统** / **Weapon Modification System**: 武器配件和改装
- 团队系统** / **Team System**: 团队对战功能
- 排行榜系统** / **Leaderboard System**: 射击统计和排名
- 成就系统** / **Achievement System**: 射击成就和奖励
#### 技术改进 / Technical Improvements
- 性能优化** / **Performance Optimization**: 进一步优化性能
- 网络同步** / **Network Synchronization**: 改善网络同步
- 错误处理** / **Error Handling**: 增强错误处理机制
### 2. 社区支持 / Community Support
#### 社区功能 / Community Features
- 用户反馈** / **User Feedback**: 收集用户反馈
- 功能投票** / **Feature Voting**: 社区功能投票
- 贡献指南** / **Contribution Guide**: 社区贡献指南
#### 文档完善 / Documentation Improvement
- API文档** / **API Documentation**: 完善API文档
- 教程视频** / **Tutorial Videos**: 制作教程视频
- 示例项目** / **Example Projects**: 提供示例项目
- 感谢使用GunPlugin!** / **Thank you for using GunPlugin!** 🎯
如有任何问题或建议,请随时联系我们! / If you have any questions or suggestions, please feel free to contact us!