Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tv.hiddlebimpf.hey.spawn.main;
- import java.util.ArrayList;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerJoinEvent;
- import org.bukkit.event.player.PlayerRespawnEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin implements Listener {
- public static ArrayList<String> spawns = new ArrayList<>();
- public void onEnable() {
- Bukkit.getConsoleSender().sendMessage("§a__________________");
- Bukkit.getConsoleSender().sendMessage("§a| |");
- Bukkit.getConsoleSender().sendMessage("§a|# # #### # #|");
- Bukkit.getConsoleSender().sendMessage("§a|# # # ### |");
- Bukkit.getConsoleSender().sendMessage("§a|#### ### # |");
- Bukkit.getConsoleSender().sendMessage("§a|# # # # |");
- Bukkit.getConsoleSender().sendMessage("§a|# # #### # |");
- Bukkit.getConsoleSender().sendMessage("§a|________________|");
- Bukkit.getConsoleSender().sendMessage("§9This HeyPlugin is: HeySpawn version: 1.0!");
- Bukkit.getConsoleSender().sendMessage("§9Developed by Hiddlebimpf_TV!");
- Bukkit.getConsoleSender().sendMessage("§9Spigot: https://bit.ly/2RokrZ0 YouTube: https://bit.ly/2lVjs5w");
- Bukkit.getPluginManager().registerEvents(this, this);
- this.reloadConfig();
- this.getConfig().options().header("HeySpawn Plugin by Hiddlebimpf_TV NOTE: I am German, which means that my translations do not have to be 100% correct.");
- //Spawn Messages
- this.getConfig().addDefault("Messages.Commands.Spawn.Success", "&8[&a&lHeySpawn&8]&a You have been&b successfully&a teleported to the spawn!");
- this.getConfig().addDefault("Messages.Commands.Spawn.Syntax", "&8[&a&lHeySpawn&8]&c Please use&b /spawn&c or&b /spawn <spawn>&c!");
- this.getConfig().addDefault("Messages.Commands.Spawn.Perms", "&8[&a&lHeySpawn&8]&c You have&b no&c rights to this!");
- this.getConfig().addDefault("Messages.Commands.Spawn.Instance", "&8[&a&lHeySpawn&8]&c You have to be a&b player&c to do that!");
- //SetSpawn Messages
- this.getConfig().addDefault("Messages.Commands.SetSpawn.Success", "&8[&a&lHeySpawn&8]&a You have&b successfully&a set the spawn!");
- this.getConfig().addDefault("Messages.Commands.SetSpawn.Syntax", "&8[&a&lHeySpawn&8]&c Please use&b /setspawn <spawn>&c!");
- this.getConfig().addDefault("Messages.Commands.SetSpawn.Perms", "&8[&a&lHeySpawn&8]&c You have&b no&c rights to this!");
- this.getConfig().addDefault("Messages.Commands.SetSpawn.Instance", "&8[&a&lHeySpawn&8]&c You have to be a&b player&c to do that!");
- //SetMainSpawn Messages
- this.getConfig().addDefault("Messages.Commands.SetMainSpawn.Success", "&8[&a&lHeySpawn&8]&a You have&b successfully&a set the mainspawn!");
- this.getConfig().addDefault("Messages.Commands.SetMainSpawn.Syntax", "&8[&a&lHeySpawn&8]&c Please use&b /setmainspawn&c!");
- this.getConfig().addDefault("Messages.Commands.SetMainSpawn.Perms", "&8[&a&lHeySpawn&8]&c You have&b no&c rights to this!");
- this.getConfig().addDefault("Messages.Commands.SetMainSpawn.Instance", "&8[&a&lHeySpawn&8]&c You have to be a&b player&c to do that!");
- //Permissions
- this.getConfig().addDefault("Permissions.Commands.Spawn", "hey.spawn.spawn");
- this.getConfig().addDefault("Permissions.Commands.SetSpawn", "hey.spawn.setspawn");
- this.getConfig().addDefault("Permissions.Commands.SetMainSpawn", "hey.spawn.setmainspawn");
- this.getConfig().addDefault("Permissions.SpawnOnJoin", "hey.spawn.spawnonjoin");
- this.getConfig().addDefault("Permissions.SpawnOnDeath", "hey.spawn.spawnondeath");
- //OtherThings
- this.getConfig().options().copyDefaults(true);
- this.saveConfig();
- }
- public void onDisable() {
- Bukkit.getConsoleSender().sendMessage("§c__________________");
- Bukkit.getConsoleSender().sendMessage("§c| |");
- Bukkit.getConsoleSender().sendMessage("§c|# # #### # #|");
- Bukkit.getConsoleSender().sendMessage("§c|# # # ### |");
- Bukkit.getConsoleSender().sendMessage("§c|#### ### # |");
- Bukkit.getConsoleSender().sendMessage("§c|# # # # |");
- Bukkit.getConsoleSender().sendMessage("§c|# # #### # |");
- Bukkit.getConsoleSender().sendMessage("§c|________________|");
- Bukkit.getConsoleSender().sendMessage("§9This HeyPlugin is: HeySpawn version: 1.0!");
- Bukkit.getConsoleSender().sendMessage("§9Developed by Hiddlebimpf_TV!");
- Bukkit.getConsoleSender().sendMessage("§9Spigot: https://bit.ly/2RokrZ0 YouTube: https://bit.ly/2lVjs5w");
- }
- @EventHandler
- public void onJoin(PlayerJoinEvent e) {
- Player p = e.getPlayer();
- if(p.hasPermission(this.getConfig().getString("Permissions.SpawnOnJoin"))) {
- final World mainworld = Bukkit.getWorld(this.getConfig().getString("MainSpawn.World"));
- final double mainx = this.getConfig().getDouble("MainSpawn.X");
- final double mainy = this.getConfig().getDouble("MainSpawn.Y");
- final double mainz = this.getConfig().getDouble("MainSpawn.Z");
- final float mainyaw = (float) this.getConfig().getDouble("MainSpawn.Yaw");
- final float mainpitch = (float)this.getConfig().getDouble("MainSpawn.Pitch");
- final Location mainspawnlocation = new Location(mainworld, mainx, mainy, mainz, mainyaw, mainpitch);
- p.teleport(mainspawnlocation);
- }
- }
- @EventHandler
- public void onRespawn(PlayerRespawnEvent e) {
- Player p = e.getPlayer();
- if(p.hasPermission(this.getConfig().getString("Permissions.SpawnOnDeath"))) {
- final World mainworld = Bukkit.getWorld(this.getConfig().getString("MainSpawn.World"));
- final double mainx = this.getConfig().getDouble("MainSpawn.X");
- final double mainy = this.getConfig().getDouble("MainSpawn.Y");
- final double mainz = this.getConfig().getDouble("MainSpawn.Z");
- final float mainyaw = (float) this.getConfig().getDouble("MainSpawn.Yaw");
- final float mainpitch = (float)this.getConfig().getDouble("MainSpawn.Pitch");
- final Location mainspawnlocation = new Location(mainworld, mainx, mainy, mainz, mainyaw, mainpitch);
- e.setRespawnLocation(mainspawnlocation);
- }
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- Player p = (Player) sender;
- String Message1 = this.getConfig().getString("Messages.Commands.SetSpawn.Success").replaceAll("&", "§");
- String Message2 = this.getConfig().getString("Messages.Commands.SetSpawn.Syntax").replaceAll("&", "§");
- String Message3 = this.getConfig().getString("Messages.Commands.SetSpawn.Perms").replaceAll("&", "§");
- String Message4 = this.getConfig().getString("Messages.Commands.SetSpawn.Instance").replaceAll("&", "§");
- String Message5 = this.getConfig().getString("Messages.Commands.SetMainSpawn.Success").replaceAll("&", "§");
- String Message6 = this.getConfig().getString("Messages.Commands.SetMainSpawn.Syntax").replaceAll("&", "§");
- String Message7 = this.getConfig().getString("Messages.Commands.SetMainSpawn.Perms").replaceAll("&", "§");
- String Message8 = this.getConfig().getString("Messages.Commands.SetMainSpawn.Instance").replaceAll("&", "§");
- String Message9 = this.getConfig().getString("Messages.Commands.Spawn.Success").replaceAll("&", "§");
- String Message10 = this.getConfig().getString("Messages.Commands.Spawn.Syntax").replaceAll("&", "§");
- String Message11 = this.getConfig().getString("Messages.Commands.Spawn.Perms").replaceAll("&", "§");
- String Message12 = this.getConfig().getString("Messages.Commands.Spawn.Instance").replaceAll("&", "§");
- if(cmd.getName().equalsIgnoreCase("setspawn")) {
- if(sender instanceof Player) {
- if(p.hasPermission(this.getConfig().getString("Permissions.Commands.SetSpawn"))) {
- if(args.length == 1) {
- this.getConfig().set(args[0] + ".World", p.getWorld().getName());
- this.getConfig().set(args[0] + ".X", p.getLocation().getX());
- this.getConfig().set(args[0] + ".Y", p.getLocation().getY());
- this.getConfig().set(args[0] + ".Z", p.getLocation().getZ());
- this.getConfig().set(args[0] + ".Yaw", p.getLocation().getYaw());
- this.getConfig().set(args[0] + ".Pitch", p.getLocation().getPitch());
- this.saveConfig();
- spawns.add(args[0]);
- p.sendMessage(Message1);
- }else
- p.sendMessage(Message2);
- }else
- p.sendMessage(Message3);
- }else
- p.sendMessage(Message4);
- }
- if(cmd.getName().equalsIgnoreCase("setmainspawn")) {
- if(sender instanceof Player) {
- if(p.hasPermission(this.getConfig().getString("Permissions.Commands.SetMainSpawn"))) {
- if(args.length == 0) {
- this.getConfig().set("MainSpawn.World", p.getWorld().getName());
- this.getConfig().set("MainSpawn.X", p.getLocation().getX());
- this.getConfig().set("MainSpawn.Y", p.getLocation().getY());
- this.getConfig().set("MainSpawn.Z", p.getLocation().getZ());
- this.getConfig().set("MainSpawn.Yaw", p.getLocation().getYaw());
- this.getConfig().set("MainSpawn.Pitch", p.getLocation().getPitch());
- this.getConfig().options().copyDefaults(true);
- this.saveConfig();
- p.sendMessage(Message5);
- }else
- p.sendMessage(Message6);
- }else
- p.sendMessage(Message7);
- }else
- p.sendMessage(Message8);
- }
- if(cmd.getName().equalsIgnoreCase("spawn")) {
- if(sender instanceof Player) {
- if(p.hasPermission(this.getConfig().getString("Permissions.Commands.Spawn"))) {
- if(args.length == 0) {
- final World mainworld = Bukkit.getWorld(this.getConfig().getString("MainSpawn.World"));
- final double mainx = this.getConfig().getDouble("MainSpawn.X");
- final double mainy = this.getConfig().getDouble("MainSpawn.Y");
- final double mainz = this.getConfig().getDouble("MainSpawn.Z");
- final float mainyaw = (float) this.getConfig().getDouble("MainSpawn.Yaw");
- final float mainpitch = (float)this.getConfig().getDouble("MainSpawn.Pitch");
- final Location mainspawnlocation = new Location(mainworld, mainx, mainy, mainz, mainyaw, mainpitch);
- Bukkit.getConsoleSender().getServer().dispatchCommand(Bukkit.getConsoleSender(), "setworldspawn" + mainspawnlocation);
- p.teleport(mainspawnlocation);
- p.sendMessage(Message9);
- }else if(args.length == 1) {
- final World world = Bukkit.getWorld(this.getConfig().getString(args[0] + ".World"));
- final double x = this.getConfig().getDouble(args[0] + ".X");
- final double y = this.getConfig().getDouble(args[0] + ".Y");
- final double z = this.getConfig().getDouble(args[0] + ".Z");
- final float yaw = (float) this.getConfig().getDouble(args[0] + ".Yaw");
- final float pitch = (float)this.getConfig().getDouble(args[0] + ".Pitch");
- final Location location = new Location(world, x, y, z, yaw, pitch);
- p.teleport(location);
- p.sendMessage(Message9);
- }else
- p.sendMessage(Message10);
- }else
- p.sendMessage(Message11);
- }else
- p.sendMessage(Message12);
- if(cmd.getName().equalsIgnoreCase("heyspawn")) {
- if(sender instanceof Player) {
- p.sendMessage(" ");
- p.sendMessage("§a# # #### # #");
- p.sendMessage("§a# # # ### ");
- p.sendMessage("§a#### ### # ");
- p.sendMessage("§a# # # # ");
- p.sendMessage("§a# # #### # ");
- p.sendMessage(" ");
- p.sendMessage("§9This HeyPlugin is: HeySpawn version: 1.0!");
- p.sendMessage("§9Developed by Hiddlebimpf_TV!");
- p.sendMessage("§9Spigot: https://bit.ly/2RokrZ0 YouTube: https://bit.ly/2lVjs5w");
- p.sendMessage("§cType§b /heyspawnhelp§c for help!");
- }else
- Bukkit.getConsoleSender().sendMessage("§8[§a§lHeySpawn§8] &8[&a&lHeySpawn&8]&c You have to be a&b player&c to do that!");
- }
- if(cmd.getName().equalsIgnoreCase("heyspawnhelp")) {
- if(sender instanceof Player) {
- if(p.hasPermission("hey.spawn.help")) {
- p.sendMessage("§aHelp for HeySpawn:");
- p.sendMessage("§aPermissions are customizable in Config.yml!");
- p.sendMessage("§b/spawn§a | Teleports you to the mainspawn! ");
- p.sendMessage("§b/spawn <spawn>§a | Teleports you to the spawn <spawn>!");
- p.sendMessage("§b/setspawn <spawn>§a | Sets a the spawn <spawn>!");
- p.sendMessage("§b/setmainspawn§a | Sets the mainspawn!");
- p.sendMessage("§b/heyspawn§a | Shows you information about this plugin!");
- p.sendMessage("§b/heyspawnhelp§a | Shows you all commands form the plugin!");
- p.sendMessage("§b/heyspawnreload§a | Reloads the plugin!");
- }else
- p.sendMessage("&8[&a&lHeySpawn&8]&c You have&b no&c rights to this!");
- }else
- Bukkit.getConsoleSender().sendMessage("§8[§a§lHeySpawn§8] &8[&a&lHeySpawn&8]&c You have to be a&b player&c to do that!");
- }
- if(cmd.getName().equalsIgnoreCase("heyspawnreload")) {
- if(sender instanceof Player) {
- if(p.hasPermission("hey.spawn.help")) {
- Bukkit.getPluginManager().disablePlugin(this);
- Bukkit.getPluginManager().enablePlugin(this);
- p.sendMessage("§8[§a§lHeySpawn§8]§a The plugin reloaded§b successfull§a!");
- }else
- p.sendMessage("&8[&a&lHeySpawn&8]&c You have&b no&c rights to this!");
- }else
- Bukkit.getConsoleSender().sendMessage("§8[§a§lHeySpawn§8] &8[&a&lHeySpawn&8]&c You have to be a&b player&c to do that!");
- }
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment