13
0

Merge branch 'master' into Particle
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
YoyoNow 2022-03-26 16:23:05 +01:00
Commit 03317f00ef
4 geänderte Dateien mit 159 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -56,6 +56,8 @@ public class LobbySystem extends JavaPlugin {
new ParticleListener(); new ParticleListener();
new InventoryInteraction(); new InventoryInteraction();
new WorldInteraction(); new WorldInteraction();
new PlayerSeatListener();
new MapsRotateListener();
new AlphaWall(l -> l.getX() > 1199, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() > 1199, AlphaWall.REFLECT_X);
new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X);

Datei anzeigen

@ -0,0 +1,38 @@
/*
* 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.lobby.command.ModifyCommand;
import org.bukkit.entity.ItemFrame;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
public class MapsRotateListener extends BasicListener {
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (ModifyCommand.modifying(event.getPlayer())) {
return;
}
if (event.getRightClicked() instanceof ItemFrame) {
event.setCancelled(true);
}
}
}

Datei anzeigen

@ -0,0 +1,116 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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 org.bukkit.*;
import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.type.Stairs;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.spigotmc.event.entity.EntityDismountEvent;
import java.util.HashSet;
import java.util.Set;
public class PlayerSeatListener extends BasicListener{
public static final World world = Bukkit.getWorlds().get(0);
private Set<Location> seats = new HashSet<>();
static {
new BukkitRunnable() {
@Override
public void run() {
for(Arrow arrow : world.getEntitiesByClass(Arrow.class)) {
arrow.setTicksLived(1);
}
}
}.runTaskTimer(LobbySystem.getPlugin(), 20*60,20*60);
}
@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 && event.getPlayer().getGameMode() != GameMode.SURVIVAL)
return;
if (((Stairs) event.getClickedBlock().getBlockData()).getHalf() != Bisected.Half.BOTTOM)
return;
if (((Stairs) event.getClickedBlock().getBlockData()).getShape() != Stairs.Shape.STRAIGHT)
return;
if (event.getPlayer().isInsideVehicle() && isArrow(event.getPlayer().getVehicle()))
event.getPlayer().getVehicle().remove();
if (event.getClickedBlock().getRelative(0, 1, 0).getType() != Material.AIR)
return;
Location location = event.getClickedBlock().getLocation();
Location seatLocation = getSeatLocation(location);
if (seats.contains(seatLocation))
return;
seats.add(seatLocation);
Arrow arrow = (Arrow) event.getPlayer().getWorld().spawnEntity(location.add(0.5, 0, 0.5), EntityType.ARROW);
arrow.setGravity(false);
arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
arrow.addPassenger(event.getPlayer());
arrow.setPersistent(true);
}
@EventHandler
public void onEntityDismount(EntityDismountEvent event) {
seats.remove(getSeatLocation(event.getDismounted().getLocation()));
if (event.getEntityType() != EntityType.PLAYER && !isArrow(event.getDismounted()))
return;
event.getDismounted().remove();
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
if (event.getPlayer().isInsideVehicle() && isArrow(event.getPlayer().getVehicle()))
event.getPlayer().getVehicle().remove();
}
public Location getSeatLocation(Location location) {
return new Location(world,location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
private boolean isArrow(Entity entity) {
return entity.getType() == EntityType.ARROW;
}
}

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.lobby.portal;
import de.steamwar.comms.packets.ExecuteCommandPacket; import de.steamwar.comms.packets.ExecuteCommandPacket;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.command.ModifyCommand;
import de.steamwar.lobby.listener.Portals; import de.steamwar.lobby.listener.Portals;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -79,7 +80,8 @@ public class CommandPortal implements PortalHandler {
cmd.append(pieces[i]).append(parts[i+1].substring(1)); cmd.append(pieces[i]).append(parts[i+1].substring(1));
} }
player.sendMessage("/" + cmd); if(ModifyCommand.modifying(player))
player.sendMessage("/" + cmd);
new ExecuteCommandPacket(player, cmd.toString()).send(player); new ExecuteCommandPacket(player, cmd.toString()).send(player);
} }