EffectLib
Wiki
Discord 支持:
论坛(已过时):
描述
此插件对服务器所有者没有用处
该库为开发者提供了一种将效果管理外包的可能性。该库自带一个方便的自定义效果集合,但您也可以轻松添加自己的效果并在库中进行管理。
用法
- 请参阅 基于 Maven 的说明文档。
- 或者,将 EffectLib.jar 添加到您的项目以及服务器的 plugins 文件夹中。
- 创建一个新的 EffectManager 来处理您的效果。
EffectManager em = new EffectManager(plugin);
- 创建一个新的 Effect 并启动它。
Effect effect = new BleedEffect(em); effect.setEntity(target); effect.start();
- 在您完全使用该库后,请释放 EffectManager。
演示
此演示会在玩家加入时创建一个流血效果。15 秒后,效果结束并调用回调函数,该函数会杀死玩家并发送一条消息。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package com.yourdomain.yourplugin;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import de.slikey.effectlib.EffectManager;
import de.slikey.effectlib.effect.BleedEffect;
public class EffectLibTest extends JavaPlugin implements Listener {
private EffectManager effectManager;
<span>@Override</span>
<span>public</span> <span>void</span> <span>onEnable</span><span>()</span> <span>{</span>
<span>Bukkit</span><span>.</span><span>getPluginManager</span><span>().</span><span>registerEvents</span><span>(</span><span>this</span><span>,</span> <span>this</span><span>);</span>
<span>// 初始化新的 EffectManager</span>
<span>effectManager</span> <span>=</span> <span>new</span> <span>EffectManager</span><span>(</span><span>this</span><span>);</span>
<span>}</span>
<span>@Override</span>
<span>public</span> <span>void</span> <span>onDisable</span><span>()</span> <span>{</span>
<span>// 释放 EffectManager</span>
<span>effectManager</span><span>.</span><span>dispose</span><span>();</span>
<span>HandlerList</span><span>.</span><span>unregisterAll</span><span>((</span><span>Listener</span><span>)</span> <span>this</span><span>);</span>
<span>}</span>
<span>@EventHandler</span>
<span>public</span> <span>void</span> <span>onPlayerJoin</span><span>(</span><span>final</span> <span>PlayerJoinEvent</span> <span>event</span><span>)</span> <span>{</span>
<span>// 创建效果并将其附加到玩家身上</span>
<span>BleedEffect</span> <span>bleedEffect</span> <span>=</span> <span>new</span> <span>BleedEffect</span><span>(</span><span>effectManager</span><span>);</span>
<span>bleedEffect</span><span>.</span><span>setEntity</span><span>(</span><span>event</span><span>.</span><span>getPlayer</span><span>());</span>
<span>// 为效果添加回调</span>
<span>bleedEffect</span><span>.</span><span>callback</span> <span>=</span> <span>new</span> <span>Runnable</span><span>()</span> <span>{</span>
<span>@Override</span>
<span>public</span> <span>void</span> <span>run</span><span>()</span> <span>{</span>
<span>event</span><span>.</span><span>getPlayer</span><span>().</span><span>sendMessage</span><span>(</span><span>"You bled out.."</span><span>);</span>
<span>event</span><span>.</span><span>getPlayer</span><span>().</span><span>setHealth</span><span>(</span><span>0</span><span>d</span><span>);</span>
<span>}</span>
<span>};</span>
<span>// 流血持续 15 秒</span>
<span>// period * iterations = 效果持续时间</span>
bleedEffect.iterations = 15 * 20;
bleedEffect.start();
}
}
|
效果控制
所有效果都可以附加到位置(setLocation)或实体上(setEntity)。某些效果(如 LineEffect)可以支持两个位置——使用 setTargetEntity 和 setTarget 来控制“第二个点”。
你可以通过调用 cancel(boolean callback) 来取消 EffectManager 中所有正在运行的效果。
基于配置的效果
还有一个基于配置的接口可供使用,即 EffectManager.start。
你可以传入作为字符串的 Effect 类名,以及作为 ConfigurationSection 的额外参数。这可以是一个完全限定的路径(用于自定义的外部定义效果),也可以是内置类的简单类名。例如:
summon:
class: VortexEffect
iterations: 4
particle: smoke
helixes: 16
circles: 7
grow: 0.1
radius: 1
然后,要使用它,类似这样的代码:
ConfigurationSection effectConfig = getConfig().getConfigurationSection("summon");
String className = effectConfig.getString("class");
effectManager.start(className, effectConfig, player);
从 3.4 版本开始,有多个不同版本的 start() 方法,其中最完整的一个看起来像这样:
effectManager.start(className, effectConfig, player.getLocation(), player, null, null, null);
后三个参数是可选的,两个“target”参数仅在某些特效中使用。最后一行可用于 TextEffect,以支持可参数化的文本消息——例如,如果你希望在基于配置的文本消息中插入玩家的名字。
当前效果列表
- ArcEffect - 创建符合建筑规范的粒子弧线
- AtomEffect - 创建原子轨道模型
- BigBangEffect - 创建大型烟花集群
- BleedEffect - 让目标实体流血
- ConeEffect - 向所有可能方向投射锥形效果
- EarthEffect - 创建地球模型
- DnaEffect - 创建 DNA 分子
- ExplodeEffect - 在指定位置创建爆炸效果
- FlameEffect - 让目标实体燃烧
- FountainEffect - 为你打造喷泉效果
- GridEffect - 为你的告示牌墙提供可定制的网格
- HelixEffect - 创建可定制的静态螺旋线
- JumpEffect - 强制实体自然跳跃
- LineEffect - 绘制从 A 到 B 的直线
- LoveEffect - 目标实体陷入爱河
- MusicEffect - 音符圆圈出现在实体上方
- MusicEffect - 音符圆圈出现在指定位置
- ShieldEffect - 实体周围的球形护盾
- SkyRocketEffect - 强制实体飞向天空
- SmokeEffect - 让目标实体冒出烟雾
- StarEffect - 创建完全可定制的 3D 星星
- TextEffect - 使用自定义字体、大小和文本创建粒子文字
- TraceEffect - 沿实体路径创建轨迹
- TurnPlayerEffect - 强制玩家进行圆周转动
- VortexEffect - 在指定位置创建粒子漩涡
- WarpEffect - 在实体周围创建扭曲效果
- WaveEffect - 创建带有冲浪效果的波浪
- 如果你编写了自己的自定义效果,欢迎发送给我!
所有效果都具备可更改性。可以让效果重复播放、增加持续时间或改变迭代周期。
任何效果在附加到静态位置或实体时都能正常工作。如果同时提供了两者,它将附着在目标位置上,但会随实体相对移动(非常适合标记命中位置,或专门附着在实体的头部或其他身体部位!)
源代码
在 GitHub 上获取源代码!
EffectLib
Wiki
Support on Discord:
Forum (Outdated):
Description
THIS PLUGIN HAS NO USE FOR SERVER-OWNERS
This library is a possibility for developers to out-source their effect-managment. This library comes with a handy collection of customizable effects, but you can easily add your own effects and manage them in the library.
Usage
- See documentation for Maven-based instructions.
- OR Add the EffectLib.jar to you project and to the plugins in your server.
- Create a new EffectManager to handle your effects.
EffectManager em = new EffectManager(plugin);
- Create a new Effect and start it.
Effect effect = new BleedEffect(em); effect.setEntity(target); effect.start();
- Dispose of the EffectManager after when you are completely done with it.
Demo
This demo creates a bleed-effect when a player joins. After 15 seconds, the effect runs out and the callback is called, that kills the player and sends them a message.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package com.yourdomain.yourplugin;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import de.slikey.effectlib.EffectManager;
import de.slikey.effectlib.effect.BleedEffect;
public class EffectLibTest extends JavaPlugin implements Listener {
private EffectManager effectManager;
<span>@Override</span>
<span>public</span> <span>void</span> <span>onEnable</span><span>()</span> <span>{</span>
<span>Bukkit</span><span>.</span><span>getPluginManager</span><span>().</span><span>registerEvents</span><span>(</span><span>this</span><span>,</span> <span>this</span><span>);</span>
<span>// Initialize a new EffectManager</span>
<span>effectManager</span> <span>=</span> <span>new</span> <span>EffectManager</span><span>(</span><span>this</span><span>);</span>
<span>}</span>
<span>@Override</span>
<span>public</span> <span>void</span> <span>onDisable</span><span>()</span> <span>{</span>
<span>// Dispose of the EffectManager</span>
<span>effectManager</span><span>.</span><span>dispose</span><span>();</span>
<span>HandlerList</span><span>.</span><span>unregisterAll</span><span>((</span><span>Listener</span><span>)</span> <span>this</span><span>);</span>
<span>}</span>
<span>@EventHandler</span>
<span>public</span> <span>void</span> <span>onPlayerJoin</span><span>(</span><span>final</span> <span>PlayerJoinEvent</span> <span>event</span><span>)</span> <span>{</span>
<span>// Create the Effect and attach it to the Player</span>
<span>BleedEffect</span> <span>bleedEffect</span> <span>=</span> <span>new</span> <span>BleedEffect</span><span>(</span><span>effectManager</span><span>);</span>
<span>bleedEffect</span><span>.</span><span>setEntity</span><span>(</span><span>event</span><span>.</span><span>getPlayer</span><span>());</span>
<span>// Add a callback to the effect</span>
<span>bleedEffect</span><span>.</span><span>callback</span> <span>=</span> <span>new</span> <span>Runnable</span><span>()</span> <span>{</span>
<span>@Override</span>
<span>public</span> <span>void</span> <span>run</span><span>()</span> <span>{</span>
<span>event</span><span>.</span><span>getPlayer</span><span>().</span><span>sendMessage</span><span>(</span><span>"You bled out.."</span><span>);</span>
<span>event</span><span>.</span><span>getPlayer</span><span>().</span><span>setHealth</span><span>(</span><span>0</span><span>d</span><span>);</span>
<span>}</span>
<span>};</span>
<span>// Bleeding takes 15 seconds</span>
<span>// period * iterations = time of effect</span>
<span>bleedEffect</span><span>.</span><span>iterations</span> <span>=</span> <span>15</span> <span>*</span> <span>20</span><span>;</span>
<span>bleedEffect</span><span>.</span><span>start</span><span>();</span>
<span>}</span>
}
|
Effects Control
All effects can attach to a Location (setLocation) or an Entity (setEntity). Some Effects (like LineEffect) can work with two locations- use setTargetEntity and setTarget to control the "second point".
You can cancel all running effects of an EffectManager by cancel(boolean callback).
Configuration-Driven Effects
There is also a Configuration-driven interface you may use, EffectManager.start.
You may pass in the Effect class as a String, and additional parameters as a ConfigurationSection. This can be a fully-qualified path (for custom externally-defined Effects) or a simple class name for the builtin classes. For example:
summon:
class: VortexEffect
iterations: 4
particle: smoke
helixes: 16
circles: 7
grow: 0.1
radius: 1
And then to use it, something like this:
ConfigurationSection effectConfig = getConfig().getConfigurationSection("summon");
String clasName = effectConfig.getString("class");
effectManager.start(className, effectConfig, player);
There are several different versions of the start() method as of 3.4, the longest one would look like this:
effectManager.start(className, effectConfig, player.getLocation(), player, null, null, null);
The latter three parameters are optional, the two "target" parameters used only in certain FX. The last line can be used for the TextEffect to have parameterizable text messages- for instance, if you wish to insert the Player's name in a Configuration-drive text message.
Current Effects
- ArcEffect - Create architectual correct arc of particles
- AtomEffect - Create the orbital-model of the atom
- BigBangEffect - Create a large cluster of fireworks.
- BleedEffect - Let the target entity bleed.
- ConeEffect - Cast a cone in all possible directions
- EarthEffect - Create a model of the Earth
- DnaEffect - Create DNA molecule
- ExplodeEffect - Create a explosion at location.
- FlameEffect - Let the target entity burn.
- FountainEffect - Create a foundtain for you well
- GridEffect - Customizable grid for you signwall
- HelixEffect - Create a customizable static helix.
- JumpEffect - Forces an entity to jump naturally.
- LineEffect - Draw line from A to B
- LoveEffect - The target entity is in love.
- MusicEffect - Circle of notes appeares above the entity.
- MusicEffect - Circle of notes appeares at a location.
- ShieldEffect - Spherical Shield around an entity.
- SkyRocketEffect - Foces an entity to fly into the sky.
- SmokeEffect - Let the target entity smoke.
- StarEffect - Create fully customizable 3D star
- TextEffect - Create particle-text with custom font, size and text
- TraceEffect - Create a trace along an entitys path.
- TurnPlayerEffect - Forces the player to turn in a circle.
- VortexEffect - Create a vortex of particles at location
- WarpEffect - Create a warp-effect around an entity
- WaveEffect - Create waves with surf.
- Feel free to send me your effects if you have coded up some custom ones of your own!
All effects have the ability to be changed. Let the effect repeat, increase duration or change period of iterations.
Any Effect will work when attached to a static location, or to an Entity. If both are provided, it will attach at the target Location, but move relative to that along with the entity (great for tagging hit locations, or attaching to an Entity's head or other body part specifically!)
Source
Get the source on GitHub!
评论 0
登录后参与评分
还没有评论,来抢沙发吧