package com.divisionactivate.factions.commands; import java.util.Collection; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitScheduler; public class portal extends BukkitRunnable { public void main() { BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); scheduler.scheduleSyncRepeatingTask(this, new Runnable() { @Override public void run() { // Do something System.out.println("test1"); Collection<? extends Player> player = Bukkit.getOnlinePlayers(); Location Officemin = new Location(Bukkit.getWorld("world"), -143,168,68); Location officemax = new Location(Bukkit.getWorld("world"), -145,170,70); for(Player p : player) { if(p.getWorld() == Bukkit.getWorld("world")) { if(p.getLocation().getX() <= Officemin.getX() && p.getLocation().getX() >= officemax.getX()) { if(p.getLocation().getZ() <= Officemin.getZ() && p.getLocation().getZ() >= officemax.getZ()) { if(p.getLocation().getY() <= Officemin.getY() && p.getLocation().getY() >= officemax.getY()) { p.teleport(Bukkit.getWorld("office").getSpawnLocation()); } } } } } } }, 0L, 0L); } }
@Jacob00524 They will never be at that block. Check a range instead. And just use a BukkitRunnable instead of a commandblock.
When i press f3 in game and look a t my block it shows that exact cord. Thats why i did block pos and not normal pos. I might sound a little mean but i promise i am grateful for your fast reply and useful.
@Jacob00524 Don't see how telling somebody where you come from help anybody. Hi Canadian, I am Timtower. The block below you has that coordinate. Your feet are on top of that block.
I have added the bucketRunnable, but now i have two more errors. First one is on Line 12 "public class portal extends BukkitRunnable {" Saying "The type portal must implement the inherited abstract method Runnable.run()" Next is Line 16, "scheduler.scheduleSyncRepeatingTask(this, new Runnable() {" saying "The type portal must implement the inherited abstract method Runnable.run()"
@Jacob00524 Looks correct to me, do you still have the error? If so, could you paste the whole class?
Code: package com.divisionactivate.factions.commands; import java.util.Collection; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_14_R1.Overridden; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitScheduler; public class portal extends BukkitRunnable { public void main() { BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); scheduler.scheduleSyncRepeatingTask(this, new Runnable() { @Overridden public void run() { // Do something System.out.println("test1"); Collection<? extends Player> player = Bukkit.getOnlinePlayers(); Location Officemin = new Location(Bukkit.getWorld("world"), -143,168,68); Location officemax = new Location(Bukkit.getWorld("world"), -145,170,70); for(Player p : player) { if(p.getWorld() == Bukkit.getWorld("world")) { if(p.getLocation().getX() <= Officemin.getX() && p.getLocation().getX() >= officemax.getX()) { if(p.getLocation().getZ() <= Officemin.getZ() && p.getLocation().getZ() >= officemax.getZ()) { if(p.getLocation().getY() <= Officemin.getY() && p.getLocation().getY() >= officemax.getY()) { p.teleport(Bukkit.getWorld("office").getSpawnLocation()); } } } } } } }, 0L, 0L); } }
@Jacob00524 My bad on the "paste the whole class" part, you already did that in the OP. :7 The reason you get that error is because your class "portal" extends BukkitRunnable but, you don't have the run() method inside that class. Fixes: 1. Don't make "portal" extend BukkitRunnable. 2. The annotation "Overridden" should be "Override" 3. I don't think you can make the scheduler run every 0 ticks, change it to 1.