SteamWar/BauSystem2.0
Archiviert
12
0

Update TNTClickListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-17 17:42:46 +01:00
Ursprung 5420c69137
Commit 1c7f044ab4
2 geänderte Dateien mit 69 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -924,6 +924,17 @@ PANZERN_NO_WORLDEDIT = §cDu hast keine WorldEdit Selection
PANZERN_PROGRESS = §e{0} §7Blöcke übrig, §e{1} §7Blöcke pro Sekunde, §e{2} §7Block Delta
PANZERN_DONE = §aZuende gepanzert
# UTILS
TNT_CLICK_HEADER = §8---=== §eTNT §8===---
TNT_CLICK_ORDER = §eEntity Order§8: §e{0}
TNT_CLICK_FUSE_TIME = §eFuseTime§8: §e{0}
TNT_CLICK_POSITION_X = §7Position §eX§8: §e{0}
TNT_CLICK_POSITION_Y = §7Position §eY§8: §e{0}
TNT_CLICK_POSITION_Z = §7Position §eZ§8: §e{0}
TNT_CLICK_VELOCITY_X = §7Velocity §eX§8: §e{0}
TNT_CLICK_VELOCITY_Y = §7Velocity §eY§8: §e{0}
TNT_CLICK_VELOCITY_Z = §7Velocity §eZ§8: §e{0}
# Warp
WARP_DISALLOWED = §cDu darfst hier nicht das Warp System nutzen
WARP_LOC_X = §7X§8: §e{0}

Datei anzeigen

@ -0,0 +1,58 @@
/*
* 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.bausystem.features.util;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.entity.Entity;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.EquipmentSlot;
@Linked(LinkageType.LISTENER)
public class TNTClickListener implements Listener {
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (event.getHand() != EquipmentSlot.HAND) {
return;
}
Entity entity = event.getRightClicked();
if (event.getRightClicked() instanceof TNTPrimed) {
TNTPrimed tntPrimed = (TNTPrimed) entity;
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_HEADER", event.getPlayer());
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ORDER", event.getPlayer(), getOrder(tntPrimed));
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_FUSE_TIME", event.getPlayer(), tntPrimed.getFuseTicks());
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_POSITION_X", event.getPlayer(), tntPrimed.getLocation().getX() + "");
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_POSITION_Y", event.getPlayer(), tntPrimed.getLocation().getY() + "");
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_POSITION_Z", event.getPlayer(), tntPrimed.getLocation().getZ() + "");
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_X", event.getPlayer(), tntPrimed.getVelocity().getX() + "");
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Y", event.getPlayer(), tntPrimed.getVelocity().getX() + "");
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Z", event.getPlayer(), tntPrimed.getVelocity().getX() + "");
}
}
private int getOrder(Entity entity) {
return entity.getEntityId() - entity.getLocation().getWorld().getEntities().stream().filter(TNTPrimed.class::isInstance).map(Entity::getEntityId).min(Integer::compareTo).orElse(0);
}
}