USkyWars API

Sep 16, 2019
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 GameEndEvent and imports the class
    5.and add your code

    Ej:

    Code (YAML):
    import teamgx.kubig.skywars.api.GameEndEvent;
    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(GameEndEvent e) {
         Player p = (Player)e.getWinner();
         Game game = GameManager.get().getP(p);
         if (game == null) {
          return;
         }
         launch_fireworks(p);
         e.setCancelled(true);
        }

        public void launch_fireworks(Player p) {
         Firework fireworks = (Firework)p.getWorld().spawn(p.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 class
  • Loading...
  • Loading...