Add Seats
Dieser Commit ist enthalten in:
Ursprung
cbca359d2d
Commit
d72e31b811
@ -24,6 +24,7 @@ import de.steamwar.spectatesystem.elements.RScoreboard;
|
||||
import de.steamwar.spectatesystem.listener.PlayerListener;
|
||||
import de.steamwar.spectatesystem.listener.CancelListener;
|
||||
import de.steamwar.spectatesystem.listener.JoinListener;
|
||||
import de.steamwar.spectatesystem.listener.PlayerSeatListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -43,6 +44,7 @@ public class SpectateSystem extends JavaPlugin {
|
||||
new JoinListener();
|
||||
new PlayerListener();
|
||||
new CancelListener();
|
||||
new PlayerSeatListener();
|
||||
try {
|
||||
acceptor = new ConnectionAcceptor();
|
||||
} catch (IOException e) {
|
||||
|
64
src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java
Normale Datei
64
src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java
Normale Datei
@ -0,0 +1,64 @@
|
||||
/*
|
||||
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.spectatesystem.listener;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.AbstractArrow;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.spigotmc.event.entity.EntityDismountEvent;
|
||||
|
||||
public class PlayerSeatListener extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if(event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if(!event.getClickedBlock().getType().name().toLowerCase().contains("stairs"))
|
||||
return;
|
||||
|
||||
if(event.getPlayer().getGameMode() != GameMode.ADVENTURE)
|
||||
return;
|
||||
|
||||
Arrow arrow = (Arrow) event.getPlayer().getWorld().spawnEntity(event.getClickedBlock().getLocation().add(0.5, 0, 0.5), EntityType.ARROW);
|
||||
arrow.setGravity(false);
|
||||
arrow.addScoreboardTag(event.getPlayer().getUniqueId().toString());
|
||||
arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
|
||||
arrow.setPassenger(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDismount(EntityDismountEvent event) {
|
||||
if(event.getEntity().getType() != EntityType.ARROW)
|
||||
return;
|
||||
|
||||
if(event.getEntityType() != EntityType.PLAYER)
|
||||
return;
|
||||
|
||||
event.getEntity().getWorld().getEntitiesByClasses(Arrow.class).forEach(entity -> {
|
||||
if(entity.getScoreboardTags().contains(event.getEntity().getUniqueId().toString()))
|
||||
entity.remove();
|
||||
});
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren