add tp to Spawn inside worlds
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package eu.mhsl.craftattack.worldmuseum.listener;
|
||||
|
||||
import eu.mhsl.craftattack.worldmuseum.worlds.World;
|
||||
import eu.mhsl.craftattack.worldmuseum.worlds.WorldManager;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.player.PlayerUseItemEvent;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
@@ -19,19 +22,25 @@ public class ClickListener implements Consumer<PlayerUseItemEvent> {
|
||||
|
||||
|
||||
|
||||
Inventory inventory = new Inventory(InventoryType.WINDOW_3X3, "asdasd");
|
||||
inventory.setItemStack(0, ItemStack.builder(Material.GRASS_BLOCK).build());
|
||||
p.openInventory(inventory);
|
||||
// Inventory inventory = new Inventory(InventoryType.WINDOW_3X3, "asdasd");
|
||||
// inventory.setItemStack(0, ItemStack.builder(Material.GRASS_BLOCK).build());
|
||||
// p.openInventory(inventory);
|
||||
|
||||
|
||||
// for (int i = 0; i < WorldManager.getInstance().getWorlds().size(); i++) {
|
||||
// World world = WorldManager.getInstance().getWorlds().get(i);
|
||||
//
|
||||
// if (world.getItem().equals(usedItem)) {
|
||||
// if (p.getInstance().equals(world)) return;
|
||||
// p.setInstance(world, world.getSpawn());
|
||||
// }
|
||||
// }
|
||||
for (int i = 0; i < WorldManager.getInstance().getWorlds().size(); i++) {
|
||||
World world = WorldManager.getInstance().getWorlds().get(i);
|
||||
|
||||
if (world.getItem().equals(usedItem)) {
|
||||
if (p.getInstance().equals(world)) {
|
||||
tpToSpawn(p, world);
|
||||
return;
|
||||
};
|
||||
p.setInstance(world, world.getSpawn());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void tpToSpawn(Player player, World world) {
|
||||
player.teleport(world.getSpawn());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user