Remove enderpearl
Dieser Commit ist enthalten in:
Ursprung
917903c439
Commit
b93d223b56
@ -41,7 +41,6 @@ public class LobbySystem extends JavaPlugin {
|
||||
pm.registerEvents(new DoubleJumpListener(), instance);
|
||||
pm.registerEvents(new ParticleListener(), instance);
|
||||
pm.registerEvents(new PlayerSeatListener(), instance);
|
||||
pm.registerEvents(new EnderPearlListener(), instance);
|
||||
|
||||
getCommand("fly").setExecutor(new FlyCommand());
|
||||
}
|
||||
|
@ -28,20 +28,9 @@ public class LobbyInventory {
|
||||
|
||||
private LobbyInventory() {}
|
||||
|
||||
public static Material PARTICLE = Material.NAME_TAG;
|
||||
public static Material ENDERPEARL_USED = Material.FIREWORK_STAR;
|
||||
public static Material ENDERPEARL_READY = Material.ENDER_PEARL;
|
||||
public static Material SHIELD = Material.SHIELD;
|
||||
public static final Material PARTICLE = Material.NAME_TAG;
|
||||
|
||||
public static void givePlayerLobbyItems(Player player) {
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
|
||||
player.getInventory().setItem(3, new ItemBuilder(lobbyPlayer.isEnderPearlUsed() ? ENDERPEARL_USED : ENDERPEARL_READY)
|
||||
.setDisplayName("§5Enderperle")
|
||||
.setUnbreakable(true)
|
||||
.removeAllAtributs()
|
||||
.build());
|
||||
|
||||
player.getInventory().setItem(5, new ItemBuilder(PARTICLE)
|
||||
.setDisplayName("§6Partikel")
|
||||
.setUnbreakable(true)
|
||||
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 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.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.inventories.LobbyInventory;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
|
||||
public class EnderPearlListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
if(event.getMaterial() != LobbyInventory.ENDERPEARL_READY) return;
|
||||
Action action = event.getAction();
|
||||
if(action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
lobbyPlayer.setEnderPearlUsed(true);
|
||||
|
||||
EnderPearl enderPearl = player.launchProjectile(EnderPearl.class);
|
||||
enderPearl.setPassenger(player);
|
||||
|
||||
LobbyInventory.givePlayerLobbyItems(player);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(LobbySystem.getInstance(), () -> {
|
||||
lobbyPlayer.setEnderPearlUsed(false);
|
||||
|
||||
if(player == null) //in case of player leave
|
||||
return;
|
||||
LobbyInventory.givePlayerLobbyItems(player);
|
||||
}, 20 * 3);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleVehicleExit(VehicleExitEvent event) {
|
||||
if(!(event.getExited() instanceof Player))
|
||||
return;
|
||||
Player player = (Player) event.getExited();
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
|
||||
lobbyPlayer.setEnderPearlUsed(false);
|
||||
LobbyInventory.givePlayerLobbyItems(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 0.5F);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void handlePlayerTeleport(PlayerTeleportEvent event) {
|
||||
if(event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) return;
|
||||
if(event.getPlayer().isInsideVehicle()) return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren