Merge pull request 'Teleporter' (#12) from Teleporter into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #12 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
24786d6987
@ -59,6 +59,7 @@ public class LobbySystem extends JavaPlugin {
|
||||
new WorldInteraction();
|
||||
new PlayerSeatListener();
|
||||
new MapsRotateListener();
|
||||
new TeleporterListener();
|
||||
new TeamPlayer();
|
||||
|
||||
new AlphaWall(l -> l.getX() > 1199, AlphaWall.REFLECT_X);
|
||||
|
@ -36,11 +36,13 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class PlayerSpawn extends BasicListener {
|
||||
|
||||
public static final int FIREWORK_SLOT = 3;
|
||||
public static final int FIREWORK_SLOT = 2;
|
||||
public static final ItemStack FIREWORK = new ItemBuilder(Material.FIREWORK_ROCKET, 1).setDisplayName("§5Rakete").build();
|
||||
public static final int PARTICLE_SLOT = 5;
|
||||
public static final int PARTICLE_SLOT = 6;
|
||||
public static final int NETHER_STAR_SLOT = 4;
|
||||
public static final ItemStack PARTICLE = new ItemBuilder(Material.NAME_TAG).setDisplayName("§6Partikel").setUnbreakable(true).removeAllAttributes().build();
|
||||
private static final ItemStack ELYTRA = new ItemBuilder(Material.ELYTRA).setDisplayName("§5Elytra").setUnbreakable(true).removeAllAttributes().build();
|
||||
public static final ItemStack NETHER_STAR = new ItemBuilder(Material.NETHER_STAR).setDisplayName("§5Teleporter").setUnbreakable(true).removeAllAttributes().build();
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
@ -66,6 +68,8 @@ public class PlayerSpawn extends BasicListener {
|
||||
player.getInventory().setItem(FIREWORK_SLOT, FIREWORK);
|
||||
|
||||
player.getInventory().setItem(PARTICLE_SLOT, PARTICLE);
|
||||
|
||||
player.getInventory().setItem(NETHER_STAR_SLOT, NETHER_STAR);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
|
73
src/de/steamwar/lobby/listener/TeleporterListener.java
Normale Datei
73
src/de/steamwar/lobby/listener/TeleporterListener.java
Normale Datei
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.lobby.listener;
|
||||
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class TeleporterListener extends BasicListener {
|
||||
|
||||
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);
|
||||
private static final Location bau = new Location(world,1951,66,1337);
|
||||
private static final Location arenen = new Location(world,2255,21,1450);
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!PlayerSpawn.NETHER_STAR.equals(event.getItem())) return;
|
||||
|
||||
SWInventory swInventory = new SWInventory(player, () -> {
|
||||
return Bukkit.createInventory(null, InventoryType.HOPPER, "§6Teleporter");
|
||||
});
|
||||
swInventory.setItem(0, new SWItem(Material.WOODEN_AXE, "§eBaubereich").getItemStack(), clickType -> {
|
||||
teleport(bau, player);
|
||||
});
|
||||
swInventory.setItem(1, new SWItem(Material.MAGMA_CREAM, "§eSpawn").getItemStack(), clickType -> {
|
||||
teleport(spawn, player);
|
||||
});
|
||||
swInventory.setItem(2, new SWItem(Material.BEACON, "§eTeamhalle").getItemStack(), clickType -> {
|
||||
teleport(team, player);
|
||||
});
|
||||
swInventory.setItem(3, new SWItem(Material.MAP, "§eMap").getItemStack(), clickType -> {
|
||||
teleport(map, player);
|
||||
});
|
||||
swInventory.setItem(4, new SWItem(Material.CLOCK, "§eArenen").getItemStack(), clickType -> {
|
||||
teleport(arenen, player);
|
||||
});
|
||||
swInventory.open();
|
||||
}
|
||||
|
||||
private void teleport(Location location, Player player) {
|
||||
player.teleport(location);
|
||||
Portals.getStack(player).clear();
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren