13
0

Teleporter #12

Zusammengeführt
Lixfel hat 12 Commits von Teleporter nach master 2022-03-26 16:51:55 +01:00 zusammengeführt
Nur Änderungen aus Commit a4afc5fe88 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -3,14 +3,18 @@ package de.steamwar.lobby.listener;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.lobby.Config;
import de.steamwar.lobby.particle.SpecialParticle;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
@ -20,6 +24,11 @@ import org.bukkit.inventory.meta.ItemMeta;
public class TeleporterListener extends BasicListener{
private static final Inventory inventory;
private static final World world = Bukkit.getWorlds().get(0);
private static final Location spawn = world.getSpawnLocation().clone().add(0.5, 0, 0.5);
private static final Location team = new Location(world,1524,55,1440);
private static final Location map = new Location(world,2337,38,1424);
static {
inventory = createInventory();
@ -34,16 +43,21 @@ public class TeleporterListener extends BasicListener{
}
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerInventoryInteract(PlayerInteractEvent event) {
ItemStack item = event.getItem();
public void handlePlayerInventoryInteract(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack item = event.getCurrentItem();
if(item == null)
return;
if(item.getType() == Material.MAGMA_CREAM && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
//TODO: TP zum Spawn
}else if(item.getType() == Material.MAP && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
//TODO: TP zur Map
if(item.getType() == Material.MAGMA_CREAM) {
player.teleport(spawn);
}else if(item.getType() == Material.BEACON) {
player.teleport(team);
}else if(item.getType() == Material.MAP) {
player.teleport(map);
}
}
private static Inventory createInventory() {
@ -55,6 +69,12 @@ public class TeleporterListener extends BasicListener{
item1.setItemMeta(meta1);
inv.setItem(1, item1);
ItemStack item2 = new ItemStack(Material.BEACON, 1);
ItemMeta meta2 = item2.getItemMeta();
meta2.setDisplayName("§eTeamhalle");
item2.setItemMeta(meta2);
inv.setItem(2, item2);
ItemStack item3 = new ItemStack(Material.MAP, 1);
ItemMeta meta3 = item3.getItemMeta();
meta3.setDisplayName("§eMap");