For episode 12
package me.illuminatiproductions.teleportbowilluminated;
import me.illuminatiproductions.teleportbowilluminated.commands.TeleportBowCommand;
import me.illuminatiproductions.teleportbowilluminated.events.SpawnEvent;
import me.illuminatiproductions.teleportbowilluminated.events.TeleportBowEvent;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
public final class TeleportBowIlluminated extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
//Setup Config
getConfig().options().copyDefaults();
saveDefaultConfig();
getCommand("tpbow").setExecutor(new TeleportBowCommand(this));
getServer().getPluginManager().registerEvents(new TeleportBowEvent(this), this);
getServer().getPluginManager().registerEvents(new SpawnEvent(this), this);
}
public void giveBow(Player player){
ItemStack teleport_bow = new ItemStack(Material.BOW);
ItemMeta meta = teleport_bow.getItemMeta();
meta.setUnbreakable(true);
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', this.getConfig().getString("bow-name")));
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.translateAlternateColorCodes('&', this.getConfig().getString("bow-description")));
meta.setLore(lore);
teleport_bow.setItemMeta(meta);
teleport_bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 666);
player.getInventory().addItem(teleport_bow);
}
}
package me.illuminatiproductions.teleportbowilluminated.events;
import me.illuminatiproductions.teleportbowilluminated.TeleportBowIlluminated;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
public class TeleportBowEvent implements Listener {
TeleportBowIlluminated plugin;
public TeleportBowEvent(TeleportBowIlluminated plugin) {
this.plugin = plugin;
}
@EventHandler
public void onBowShoot(ProjectileHitEvent e){
Player player = (Player) e.getEntity().getShooter();
Location location = e.getEntity().getLocation();
e.getEntity().remove();
location.setYaw(player.getLocation().getYaw());
location.setPitch(player.getLocation().getPitch());
player.teleport(location);
player.playSound(location, Sound.ENTITY_DRAGON_FIREBALL_EXPLODE, 1.0F, 1.0F);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("teleported-message")));
}
}
package me.illuminatiproductions.teleportbowilluminated.events;
import me.illuminatiproductions.teleportbowilluminated.TeleportBowIlluminated;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class SpawnEvent implements Listener {
TeleportBowIlluminated plugin;
public SpawnEvent(TeleportBowIlluminated plugin) {
this.plugin = plugin;
}
@EventHandler
public void onSpawnEvent(PlayerJoinEvent e){
if (plugin.getConfig().getBoolean("give-bow-on-join")){
Player player = e.getPlayer();
if (player.hasPermission("tpbow.join")) {
plugin.giveBow(player);
}
}
}
}
package me.illuminatiproductions.teleportbowilluminated.commands;
import me.illuminatiproductions.teleportbowilluminated.TeleportBowIlluminated;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class TeleportBowCommand implements CommandExecutor {
TeleportBowIlluminated plugin;
public TeleportBowCommand(TeleportBowIlluminated plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player){
Player player = (Player) sender;
if(player.hasPermission("tpbow.spawnbow")){
plugin.giveBow(player);
}else{
player.sendMessage("You do not have the permissions required to execute this.");
}
}
return true;
}
}
name: TeleportBowIlluminated
version: ${project.version}
main: me.illuminatiproductions.teleportbowilluminated.TeleportBowIlluminated
api-version: 1.13
authors: [Illuminatiiiiii]
description: The best version of the teleport bow. It's illuminated.
website: https://youtube.com/c/IlluminatiProductions
commands:
tpbow:
description: Spawn a teleport bow
usage: /<command>
aliases:
- teleportbow
bow-name: '&f[&eTeleport&aBow&f]'
bow-description: '&6Shoot your shot and teleport anywhere.'
teleported-message: '&aSwoosh!'
give-bow-on-join: true