SteamWar/BauSystem2.0
Archiviert
12
0
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
BauSystem2.0/BauSystem_15/src/de/steamwar/bausystem/entities/TraceEntity15.java

74 Zeilen
2.4 KiB
Java

/*
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.bausystem.entities;
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.shared.BaseEntity15;
2021-04-18 00:16:08 +02:00
import de.steamwar.bausystem.shared.ReferenceCounter;
import net.minecraft.server.v1_15_R1.ChatComponentText;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class TraceEntity15 extends BaseEntity15 implements AbstractTraceEntity {
private boolean exploded = false;
2021-04-18 00:16:08 +02:00
private ReferenceCounter referenceCounter = new ReferenceCounter();
public TraceEntity15(World world, Vector position, boolean tnt) {
2021-04-18 00:16:08 +02:00
super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS);
this.setNoGravity(true);
this.ticksLived = -12000;
}
@Override
public void display(Player player, boolean exploded, int ticks) {
if (ticks != -1) {
this.setCustomNameVisible(true);
this.setCustomName(new ChatComponentText(ticks + ""));
}
if (!this.exploded && exploded) {
this.setCustomNameVisible(true);
this.setCustomName(new ChatComponentText("Bumm"));
this.exploded = true;
2021-04-18 00:16:08 +02:00
if (referenceCounter.increment() > 0) {
sendEntityDestroy(player);
2021-04-18 00:16:08 +02:00
}
} else if (referenceCounter.increment() > 0) {
return;
2021-04-18 00:16:08 +02:00
}
2021-04-18 00:16:08 +02:00
sendEntity(player);
}
@Override
public boolean hide(Player player, boolean force) {
2021-04-18 00:16:08 +02:00
if (!force && referenceCounter.decrement() > 0) {
return false;
2021-04-18 00:16:08 +02:00
}
sendEntityDestroy(player);
die();
return true;
}
}