Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.AceLV.RandomTeleport;
- import java.io.File;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin {
- @Override
- public void onEnable() {
- if(!new File(this.getDataFolder(), "config.yml").exists()) {
- this.saveDefaultConfig();
- }
- if(this.getConfig().getBoolean("onCommand"));
- }
- @Override
- public void onDisable() {
- }
- public boolean onCommand(CommandSender thesender, Command cmd, String commandLabel, String[] args)
- {
- if(commandLabel.equalsIgnoreCase("rt"))
- {
- Player player = (Player) thesender;
- int randomX = (int) (Math.random() * 1000);
- int randomZ = (int) (Math.random() * 1000);
- int randomY = player.getWorld().getHighestBlockYAt(randomX, randomZ);
- Location randomLocation = new Location(player.getWorld(), randomX, randomY, randomZ);
- if(player.hasPermission("RandomTeleport.tp"))
- player.teleport(randomLocation);
- else player.sendMessage(ChatColor.RED + "You dont have permissions, to do that!");
- if(player.hasPermission("RandomTeleport.tp"))
- player.sendMessage(getConfig().getString("teleport-message"));
- return true;
- }
- //This will make the player variable
- Player player = (Player) thesender;
- //This will get the string from the config
- String Config = this.getConfig().getString("teleport-message");
- //This will replace the {Player} With the name
- String Replaced = Config.replace("{Player}", player.getName());
- //This will translate the color codes!
- player.sendMessage(ChatColor.translateAlternateColorCodes('&', Replaced));
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement