Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.TooManyMobs.bay;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.EventPriority;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.AsyncPlayerChatEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin implements Listener {
- public void onEnable() {
- getServer().getPluginManager().registerEvents(this, this);
- this.saveDefaultConfig();
- }
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
- Player p = event.getPlayer();
- {
- if (event.getMessage().equalsIgnoreCase(".sethome")) {
- int x = p.getLocation().getBlockX();
- int y = p.getLocation().getBlockY();
- int z = p.getLocation().getBlockZ();
- String worldname = p.getWorld().getName();
- getConfig().set("home." + p.getUniqueId() + ".x", x);
- getConfig().set("home." + p.getUniqueId() + ".y", y);
- getConfig().set("home." + p.getUniqueId() + ".z", z);
- getConfig().set("home." + p.getUniqueId() + ".world", worldname);
- p.sendMessage(ChatColor.YELLOW + "Your home has been set!");
- saveConfig();
- }
- if (event.getMessage().equalsIgnoreCase(".home")) {
- int x = getConfig().getInt("home." + p.getUniqueId() + ".x");
- int y = getConfig().getInt("home." + p.getUniqueId() + ".y");
- int z = getConfig().getInt("home." + p.getUniqueId() + ".z");
- String worldname = getConfig().getString("home." + p.getUniqueId() + ".world");
- World world = getServer().getWorld(worldname);
- Location l = new Location (world,x,y,z);
- p.teleport(l);
- p.sendMessage(ChatColor.YELLOW + "You have been sent home!");
- }
- if (event.getMessage().equalsIgnoreCase(".spawn")) {
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "scoreboard players set " + p.getName() + " spawn 10");
- p.sendMessage(ChatColor.YELLOW + "You have been sent to spawn!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement