Ok so im making a plugin so that you can create portals by clicking a diamond block with a stick and then you do ./wc portal create and then when you step on the diamond block after that it will randomly teleport you, heres me code, I have no idea how do to the create portal points, my main class that does it by command Code:java package me.JoeyLangston.MCTeleport; import java.util.ArrayList;import java.util.Random; import org.bukkit.Bukkit;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.event.Listener;import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin implements Listener { ArrayList<Player> cooldown = new ArrayList<Player>(); public void onEnable() { Bukkit.getServer().getPluginManager().registerEvents(this, this); } public void onDisable() { getLogger().info("MC-Teleport is now disabled."); } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { final Player p = (Player) sender; if(cmd.getName().equalsIgnoreCase("Wilderness")){ if(cooldown.contains(p)) { p.sendMessage(ChatColor.YELLOW + "You must wait 5 seconds before using this command again!"); return true; } Location loc = p.getLocation(); Random rand = new Random(); loc.setX(rand.nextInt(1001)-500); loc.setZ(rand.nextInt(1001)-500); loc.setY(5); p.sendMessage(ChatColor.YELLOW + "You Have Been Randomly Teleported!"); p.teleport(loc); loc.add(0,69,0); cooldown.add(p); Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run(){ cooldown.remove(p); } },100); return true; } return false; }} My portal class which doesnt even work Code:java package me.JoeyLangston.MCTeleport; import java.util.Random; import org.bukkit.ChatColor;import org.bukkit.Location;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerMoveEvent; public class Portal implements Listener { @SuppressWarnings("deprecation") @EventHandler public void moveEvent(PlayerMoveEvent e) { //Checks if the player moves Player player = e.getPlayer(); Location loc = player.getPlayer().getLocation(); loc.setY(loc.getY() -1); int block = loc.getWorld().getBlockTypeIdAt(loc); if(block == 57) { Random rand = new Random(); loc.setX(rand.nextInt(1001)-500); loc.setZ(rand.nextInt(1001)-500); loc.setY(5); player.sendMessage(ChatColor.YELLOW + "You Have Been Randomly Teleported!"); } } } EDIT by Moderator: merged posts, please use the edit button instead of double posting.
try registering that class in your onEnable like this Code: public void onEnable(){ getServer().getPluginManager().registerEvents(new Portal(), this); }
If you look at my portable portals plugin you can see how to make portals the "Cheaper" way(getting target from the item lore)