⚙️ 核心系统
- Twitch 账号绑定
玩家可以使用简单的游戏内命令将 Minecraft 账号绑定到其 Twitch 账号。这是追踪观看时长和奖励的基础。
- 命令:
/linktwitch <twitch_username>
- 存储: 绑定的账号以
twitch_username: minecraft_uuid 的格式存储在 usernames.yml 中。
- 主播配置
服务器管理员可以轻松配置要追踪的主要 Twitch 频道。插件将监控该频道的直播状态更新。
- 配置: 在
config.yml 中设置 twitch_channel 和 twitch_link。
- API 集成: 需要在
config.yml 中添加 Twitch Client ID 和 Secret,以便与 Twitch API 进行通信。
- 直播公告
当配置的主播开播时,会向服务器上的所有玩家广播可自定义的公告,鼓励他们加入直播间。
- 配置: 在
config.yml 中启用或禁用此功能,并自定义消息内容。
- 示例消息:
§d[Live] %streamer% is now streaming! Watch at: %streamlink%
- 观看时长追踪系统
插件会追踪所有已绑定且在线的玩家在主播放映期间的观看时长。
- 逻辑: 每秒运行一个异步任务来检查主播的直播状态,并为在线的已绑定玩家更新观看时长。
- 存储: 每个玩家的观看时长数据存储在
time.yml 中,包括 seconds_watched(已观看秒数)和 unclaimed_rewards(未领取奖励)。
- 奖励间隔逻辑
根据可配置的时间间隔自动向玩家发放奖励。
- 配置: 在
config.yml 中设置 reward_interval(以秒为单位)、reward_type(points 或 item)以及具体的 reward。
- 示例: 如果
reward_interval 为 600,则玩家每观看 10 分钟即可获得一次奖励。
- 离线奖励处理
如果玩家在离线期间获得了奖励,插件会将其存储为“未领取奖励”。当玩家重新登录时,他们会收到通知并获得一个唯一的兑换码来领取奖励。
- 逻辑:
PlayerJoinEvent 监听器会检查未领取的奖励并生成兑换码。
- 通知: 玩家会收到类似如下消息:
§eYou’ve earned rewards for watching %streamer%! Use /twitchredeem <code> to claim them.
- 兑换码系统
使用唯一代码灵活兑换奖励的系统。代码可以针对离线奖励自动生成,也可以由主播/管理员手动生成。
- 存储: 代码及其
reward_type、reward 和 uses_left(剩余使用次数)存储在 redeemcodes.yml 中。
- 过期: 当代码的
uses_left 降至 0 时,代码会自动移除。
- 主播奖励码生成
主播和管理员可以生成自定义奖励码,以便在直播期间与观众分享。
- 命令:
/twitchreward generate
- 配置: 在
config.yml 中配置生成代码的奖励类型、数值和使用次数。
- Twitch 积分系统
插件内置的货币系统,允许玩家积累作为奖励的“Twitch Points”(Twitch 积分)。
- 存储: 玩家的积分余额存储在
twitchpoints.yml 中。
- 命令: 玩家可以使用
/twitchpoints 查看自己的余额。
- 观看时长追踪(通过 Twitch IRC)
为了提供准确的观看时长追踪系统,TwitchRewards999 现在直接集成 Twitch IRC。该系统追踪积极参与直播间聊天的玩家。
- 工作原理:
- Minecraft 插件通过 Twitch IRC 连接到主播的 Twitch 聊天室。
- 它追踪进入或离开聊天室的用戶,以及发送消息的用户。
- 只有被识别为活跃聊天者的玩家才会被追踪观看时长。
- 设置:
- 在插件的
config.yml 中配置你的 Twitch Client ID、Client Secret 和 OAuth Token。
第一部分:设置 Twitch 扩展
-
创建新的 Twitch 扩展:
- 前往 Twitch Developer Console。
- 点击左侧菜单中的“Extensions”(扩展)。
- 点击“Create an Extension”(创建扩展)。
- 为你的扩展命名(例如“MyRewardsExtension”),并选择“Panel”作为扩展类型。
- 点击“Create Extension”(创建扩展)。
-
获取你的扩展凭据:
- 在你的扩展仪表板中,你会看到你的 Client ID。
- 点击“Settings”(设置)选项卡。你的 Extension Secret 就在这里。
-
生成并上传前端文件:
- 启动安装了 TwitchRewards999 插件的 Minecraft 服务器。这将自动生成
extension_frontend 文件夹,其中包含 panel.html 和 viewer.js,位于插件配置文件夹的同一目录下(例如 plugins/TwitchRewards999/extension_frontend)。
- 进入扩展仪表板的“Asset Hosting”(资源托管)选项卡。
- 将新生成的
extension_frontend 文件夹的内容(panel.html 和 viewer.js)拖放到上传区域。
- 将“Panel Viewer Path”(面板查看器路径)设置为
panel.html。
- 点击“Save Changes”(保存更改)。
第二部分:设置 Minecraft 插件
-
安装插件:
- 将
TwitchRewards999-1.0.0.jar 文件(来自 target 目录)放入 Spigot 服务器的 plugins 文件夹中。
- 启动 Minecraft 服务器。这将生成插件的配置文件。
-
配置插件:
- 打开
plugins/TwitchRewards999/config.yml 文件。
- 将
twitch_channel 设置为你的 Twitch 用户名(你要追踪的频道)。
- 将
twitch_link 设置为你的 Twitch 频道 URL。
- 填入你的
twitch_client_id 和 twitch_client_secret(与你 Twitch 扩展中的相同)。
- 获取 Twitch OAuth Token:
- 前往 Twitch Chat OAuth 密码生成器(例如 )。
- 授权该应用程序以获取你的 OAuth token,它将以前缀
oauth: 开头。
- 复制完整的 token。
- 在
config.yml 中将 twitch_oauth_token 设置为你刚刚获得的 OAuth token。
- 根据你的喜好自定义其余设置(奖励、消息等)。
- 保存
config.yml 文件并重启服务器,或运行 /twitchreload。
第 3 部分:最后步骤
-
激活扩展:
- 返回你的 Twitch 扩展仪表板。
- 进入“版本状态”选项卡,并按照步骤将你的扩展移至“托管测试”状态,然后移至“已发布”状态。
- 发布后,你可以通过访问创作者仪表板 -> 扩展 -> 我的扩展,在你的频道上安装该扩展。
-
测试系统:
- 在 Twitch 上开始直播,并确保扩展处于活动状态。
- 让一名玩家在游戏中通过
/linktwitch <their_twitch_username> 链接他们的 Twitch 账号。
- 观看达到配置的
reward_interval 时长。
- 你应该能看到游戏中发放了奖励。
- 检查服务器控制台是否有错误信息。
你现在已成功设置了完整的 TwitchRewards999 系统!
? 命令
| 命令 |
描述 |
权限 |
/linktwitch <twitch_user> |
将你的 Minecraft 账号链接到你的 Twitch 账号。 |
(所有人) |
/twitchpoints |
显示你当前的 Twitch 积分余额。 |
(所有人) |
/twitchreward generate |
为主播生成一个可供分享的奖励代码。 |
twitchreward.admin |
/twitchredeem <code> |
兑换存储或共享的奖励代码。 |
(所有人) |
/twitchreload |
重新加载插件的配置和数据。 |
twitchreward.admin |
/twitchtime <player> |
查看玩家的观看时间和未领取的奖励。 |
twitchreward.admin |
⚙️ Core Systems
- Twitch Account Linking
Players can link their Minecraft account to their Twitch account using a simple in-game command. This is the foundation for tracking watch time and rewards.
- Command:
/linktwitch <twitch_username>
- Storage: Linked accounts are stored in
usernames.yml in the format twitch_username: minecraft_uuid.
- Streamer Configuration
Server administrators can easily configure the main Twitch channel to be tracked. The plugin will monitor this channel for live status updates.
- Configuration: Set the
twitch_channel and twitch_link in config.yml.
- API Integration: Requires a Twitch Client ID and Secret to be added to the
config.yml for Twitch API communication.
- Live Announcements
When the configured streamer goes live, a customizable announcement is broadcast to all players on the server, encouraging them to join the stream.
- Configuration: Enable or disable this feature and customize the message in
config.yml.
- Example Message:
§d[Live] %streamer% is now streaming! Watch at: %streamlink%
- Watch Time Tracking System
The plugin tracks the watch time of all linked players who are online on the Minecraft server while the streamer is live.
- Logic: An asynchronous task runs every second to check the streamer's live status and update the watch time for online, linked players.
- Storage: Watch time data is stored in
time.yml for each player, including seconds_watched and unclaimed_rewards.
- Reward Interval Logic
Rewards are automatically granted to players based on a configurable time interval.
- Configuration: Set the
reward_interval (in seconds), reward_type (points or item), and the reward itself in config.yml.
- Example: If
reward_interval is 600, a player will receive a reward for every 10 minutes of watch time.
- Offline Reward Handling
If a player earns a reward while they are offline, the plugin stores it as an "unclaimed reward". When the player logs back in, they are notified and given a unique code to redeem their rewards.
- Logic: A
PlayerJoinEvent listener checks for unclaimed rewards and generates a redeem code.
- Notification: The player receives a message like:
§eYou’ve earned rewards for watching %streamer%! Use /twitchredeem <code> to claim them.
- Redeem Code System
A flexible system for redeeming rewards using unique codes. Codes can be generated automatically for offline rewards or manually by streamers/admins.
- Storage: Codes are stored in
redeemcodes.yml with their reward_type, reward, and uses_left.
- Expiration: Codes are automatically removed when their
uses_left reaches 0.
- Streamer Reward Code Generation
Streamers and administrators can generate custom reward codes to share with their audience during a stream.
- Command:
/twitchreward generate
- Configuration: The reward type, value, and number of uses for generated codes can be configured in
config.yml.
- Twitch Points System
An in-plugin currency system that allows players to accumulate "Twitch Points" as rewards.
- Storage: Player point balances are stored in
twitchpoints.yml.
- Command: Players can check their balance with
/twitchpoints.
- Watch Time Tracking (via Twitch IRC)
To provide an accurate watch time tracking system, TwitchRewards999 now integrates directly with Twitch IRC. This system tracks players who are actively participating in the stream's chat.
- How it works:
- The Minecraft plugin connects to the streamer's Twitch chat via Twitch IRC.
- It tracks users who join or leave the chat, and those who send messages.
- Only players who are identified as active chatters will have their watch time tracked.
- Setup:
- Configure your Twitch Client ID, Client Secret, and OAuth Token in the plugin's
config.yml.
Part 1: Setting up the Twitch Extension
-
Create a new Twitch Extension:
- Go to the Twitch Developer Console.
- Click on "Extensions" in the left-hand menu.
- Click "Create an Extension".
- Give your extension a name (e.g., "MyRewardsExtension") and select "Panel" as the extension type.
- Click "Create Extension".
-
Get your Extension Credentials:
- In your extension's dashboard, you will see your Client ID.
- Click on the "Settings" tab. Your Extension Secret is here.
-
Generate and Upload the Frontend Files:
- Start your Minecraft server with the TwitchRewards999 plugin installed. This will automatically generate the
extension_frontend folder containing panel.html and viewer.js in the same directory as your plugin's configuration folder (e.g., plugins/TwitchRewards999/extension_frontend).
- Go to the "Asset Hosting" tab in your extension's dashboard.
- Drag and drop the contents of the newly generated
extension_frontend folder (panel.html and viewer.js) into the upload area.
- Set the "Panel Viewer Path" to
panel.html.
- Click "Save Changes".
Part 2: Setting up the Minecraft Plugin
-
Install the Plugin:
- Place the
TwitchRewards999-1.0.0.jar file (from the target directory) into your Spigot server's plugins folder.
- Start your Minecraft server. This will generate the plugin's configuration files.
-
Configure the Plugin:
- Open the
plugins/TwitchRewards999/config.yml file.
- Set the
twitch_channel to your Twitch username (the channel you want to track).
- Set the
twitch_link to your Twitch channel URL.
- Fill in your
twitch_client_id and twitch_client_secret (the same ones from your Twitch Extension).
- Obtain a Twitch OAuth Token:
- Go to a Twitch Chat OAuth Password Generator (e.g., ).
- Authorize the application to get your OAuth token. It will start with
oauth:.
- Copy the full token.
- Set the
twitch_oauth_token in config.yml to the OAuth token you just obtained.
- Customize the rest of the settings (rewards, messages, etc.) to your liking.
- Save the
config.yml file and restart your server or run /twitchreload.
Part 3: Final Steps
-
Activate the Extension:
- Go back to your Twitch Extension's dashboard.
- Go to the "Version Status" tab and follow the steps to move your extension to "Hosted Test" and then to "Released".
- Once released, you can install the extension on your own channel by going to your Creator Dashboard -> Extensions -> My Extensions.
-
Test the System:
- Start streaming on Twitch with the extension active.
- Have a player link their Twitch account in-game with
/linktwitch <their_twitch_username>.
- Watch the stream for the configured
reward_interval.
- You should see rewards being granted in-game.
- Check the server console for any errors.
You have now successfully set up the complete TwitchRewards999 system!
? Commands
| Command |
Description |
Permission |
/linktwitch <twitch_user> |
Link your Minecraft account to your Twitch account. |
(everyone) |
/twitchpoints |
Shows your current Twitch Points balance. |
(everyone) |
/twitchreward generate |
Generates a reward code for the streamer to share. |
twitchreward.admin |
/twitchredeem <code> |
Redeem a stored or shared reward code. |
(everyone) |
/twitchreload |
Reloads the plugin's configuration and data. |
twitchreward.admin |
/twitchtime <player> |
See a player's watch time and unclaimed rewards. |
twitchreward.admin |
评论 0
登录后参与评分
还没有评论,来抢沙发吧