That One Spawn Plugin
这是一个极简主义的插件,用于在整个服务器中维护一个单一的出生点。它的设计理念侧重于易用性、高效性、与其他插件的兼容性以及简洁的功能。请参阅 6.5 章节以了解我开发此插件的原因。
命令
/spawn - 传送至出生点
/setspawn - 设置出生点
/reloadspawn - 重载配置文件
权限
不需要权限插件!
默认情况下,非管理员(non-ops)可以前往出生点,而管理员(ops)可以设置和重载出生点。这适用于大多数情况,但如果您有其他需求,始终可以通过权限节点进行覆盖。
权限节点
- spawn.goToSpawn - 允许前往出生点
- spawn.setSpawn - 允许设置出生点
- spawn.reloadSpawn - 允许重载出生点
我还添加了一些更易于记忆的便捷节点:
- spawn.user - 允许前往出生点
- spawn.admin - 允许设置和重载出生点
- spawn.* - 允许使用所有出生点相关命令
配置
默认值:
GoToSpawnOnDeath: true
letOtherPluginsChangeSpawn: true
GoToSpawnOnDeath - 如果此项为 true,则玩家死亡后将被传送至出生点。如果您希望由其他插件决定重生位置(例如家园插件),或者希望玩家在床铺处重生,请将其设置为 false。
letOtherPluginsChangeSpawn - 如果此项为 true,则允许其他插件更改出生点。如果此项为 false,则此插件将阻止其他插件更改世界中的出生点。具体效果可能取决于该插件的编写方式;如果更改的不是主出生点所在世界的出生点,则此选项不会生效。
安装
这是一个非常简单的即插即用插件。对于大多数用户来说,无需进行任何设置。只需将插件放入 plugins 文件夹并重启服务器即可。以管理员身份或有权限的用户登录,站在您 desired 的出生点位置,然后执行 /setspawn 命令。
结语
理念
我喜欢这样的理念:每个插件只负责一项工作,并将其做好。即使这可能并不完全符合事实,但我认为同时承担过多职责的插件无法将其功能发挥到极致。
底层机制
此插件具有高度可扩展性和极高的效率。它将出生点数据写入并保存至扁平文件(Config.yml)。然而,它也会将出生点位置保留在内存中以便快速访问。仅当内存中不存在该位置时,才会从文件中读取。这可能有些过度设计,但正如我所说,我喜欢这种“插件只做一件事并把它做好”的理念。
Unlicense
本代码放弃实际版权许可,进入公共领域。您可以随意使用它。您甚至可以重新提交并声称是您的作品(尽管没人喜欢抄袭者)。
源代码
源代码可在 此处 找到。
源代码文档详尽,因此如果您是希望入门插件编程的新手,我认为这个插件的源码将是一个宝贵的资源。
为什么还要制作另一个出生点插件?
我找不到一个能满足我需求的简单出生点插件
感谢
如果您有任何问题、评论或疑虑,请给我发送私信。我不常查看插件评论区的内容。
That One Spawn Plugin
This is a minimalistic plugin that maintains a single spawnpoint for the entire server. It was designed with ease of use, efficiency, compatibility with other plugins and simple functionality in mind. See section 6.5 as to why I made it.
Commands
/spawn - Takes you to spawn
/setspawn - Sets the spawn
/reloadspawn - Reloads the config file
Permissions
A permissions plugin is not required!
By default not-ops can go to spawn and ops can set and reload spawn. This should be fine for most cases, but can always be overridden with permissions if you have something else in mind.
Nodes
- spawn.goToSpawn - Allows one to go to spawn
- spawn.setSpawn - Allows one to set the spawn
- spawn.reloadSpawn - Allows one to reload the spawn
I added some convenience nodes that are easier to remember:
- spawn.user - Allows one to go to spawn
- spawn.admin - Allows one to set and reload the spawn
- spawn.* - Allows use of all spawn commands
Configuration
Defaults:
GoToSpawnOnDeath: true
letOtherPluginsChangeSpawn: true
GoToSpawnOnDeath - If this is true then players will be teleported to spawn on death. Set this to false if you want another plugin to decide where they respawn (like a homes plugin), or if you want them to respawn at their beds.
letOtherPluginsChangeSpawn - If this is true, then another plugin can change the spawn. If this is false, then this plugin will stop a plugin from changing the spawn of the world. This might not do anything depending on how that plugin is written, and will not do anything if the spawn of a world other than the world the main spawn is in is being changed.
Installation
This is a very simple plug-and-play plugin. For most users, no setup should be required. Just put the plugin in the plugins folder and reload the server. Log in as an op or someone with permissions, stand at your desired spawnpoint and issue /setspawn.
Final Remarks
Philosophy
I like the thought of plugins having one job, and doing them well. Even if it may not be true, I feel like plugins juggling too many responsibilities at once don't do those things to the best of their abilities.
Under the Hood
This plugin should be highly scalable and very efficient. It writes and saves the spawn to flatfile (Config.yml). However, it also keeps the spawn location in memory for quick access. It only reads from the file if the location is not in memory. This might be overkill, but like I said, I like the thought of a plugin having one job and doing it well.
Unlicense
This code is waived of an actual license and is open to the public domain. You may do whatever you want with it. You could even resubmit it and say that you made it (but nobody likes a plagiarist).
Source
Source can be found Here.
The source is heavily documented, so if you're a newbie hoping to get into plugin programming, I think that the source for this plugin would be a valuable resource.
Why Make Another Spawn Plugin?
I couldn't find a simple spawn plugin that suited my needs
Thank you
If you have any questions comments or concerns, send me a pm. I don't check the comments sections of my plugins very often.
评论 0
登录后参与评分
还没有评论,来抢沙发吧