USkyWars API
-
How to use the new api:
1.Create the class where you are going to use the api
2.now the class you created implements the listener
3.create the public void and add @EventHandler to it
4.and to this public void between parentesis adds the GameWinEffect and imports the class
5.and add your code
Ej:
Code (YAML):
import teamgx.kubig.skywars.api.GameWinEvent;
import teamgx.kubig.skywars.game.Game;
import teamgx.kubig.skywars.manager.GameManager;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.entity.Firework;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class GameWinEffect
implements Listener {
@EventHandler
public void onGameEnd(GameWinEvent e) {
GameTeam team = e.getWinner();
for(GamePlayer gamePlayer : team.getPlayer()) {
if(gamePlayer != null) {
launch_fireworks(gamePlayer);
e.setCancelled(true);
}
}
}
public void launch_fireworks(GamePlayer gamePlayer) {
Firework fireworks = (Firework)gamePlayer.getPlayer().getWorld().spawn(gamePlayer.getPlayer().getLocation().clone().add(0.5D, 0.5D, 0.5D), Firework.class);
FireworkMeta fireworksmeta = fireworks.getFireworkMeta();
FireworkEffect fireworkseffect = FireworkEffect.builder().with(FireworkEffect.Type.BALL).withColor(Color.YELLOW).withFade(Color.AQUA).flicker(true).trail(true).build();
fireworksmeta.setPower(1);
fireworksmeta.addEffect(fireworkseffect);
fireworks.setFireworkMeta(fireworksmeta);
}
}
6. and register the class where the event is with the Bukkit.getPluginManager().registerEvents(new GameWinEffect(), this); in the main class1.Create class
2.Aggregate Extension Class SoulAnimationAPI
3.Add the methods
4.Enter your code
Ej:
Code (YAML):
package teamgx.example.uskywars.animation;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.scheduler.BukkitRunnable;
import teamgx.kubig25.uskywars.USkyWars;
import teamgx.kubig25.uskywars.api.SoulAnimationAPI;
public class SoulAnimation
extends SoulAnimationAPI {
@Override
public void onServer(Location location) {}
@Override
public void before(Player player, Location location) {}
@Override
public void start(Player player, Location location) {
new BukkitRunnable() {
public void run() {
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 5);
}
}.runTaskLater(USkyWars.get(), 1L);
}
@Override
public void end(Player player, Location location) {
Firework fw = (Firework)location.getWorld().spawn(location, Firework.class);
FireworkMeta data = fw.getFireworkMeta();
data.addEffects( new FireworkEffect[] { FireworkEffect.builder().withColor(Color.RED).with(FireworkEffect.Type.BALL).build() });
data.setPower(1);
fw.setFireworkMeta(data);
new BukkitRunnable() {
public void run() {
fw.detonate();
}
}.runTaskLater(USkyWars.get(), 1L);
}
@Override
public void after(Player player, Location location) {}
@Override
public void offServer(Location location) {}
}
Ej:
settings:
animation: teamgx.example.uskywars.animation.SoulAnimation - Loading...
- Loading...
XenCarta PRO
© Jason Axelrod from 8WAYRUN.COM