2022-02-10 16:28:15 +01:00
|
|
|
/*
|
|
|
|
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.BaseEntity18;
|
|
|
|
import de.steamwar.bausystem.shared.ReferenceCounter;
|
2022-02-10 17:35:12 +01:00
|
|
|
import net.minecraft.network.chat.ChatComponentText;
|
2022-02-10 16:28:15 +01:00
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
|
|
|
public class TraceEntity18 extends BaseEntity18 implements AbstractTraceEntity {
|
|
|
|
|
|
|
|
private boolean exploded = false;
|
|
|
|
private ReferenceCounter referenceCounter = new ReferenceCounter();
|
|
|
|
|
|
|
|
public TraceEntity18(World world, Vector position, boolean tnt) {
|
|
|
|
super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS);
|
|
|
|
|
2022-02-10 17:35:12 +01:00
|
|
|
this.e(true);
|
|
|
|
this.S = -12000;
|
2022-02-10 16:28:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void display(Player player, boolean exploded, int ticks) {
|
|
|
|
if (ticks != -1) {
|
2022-02-10 17:35:12 +01:00
|
|
|
this.n(true);
|
|
|
|
this.a(new ChatComponentText(ticks + ""));
|
2022-02-10 16:28:15 +01:00
|
|
|
}
|
|
|
|
if (!this.exploded && exploded) {
|
2022-02-10 17:35:12 +01:00
|
|
|
this.n(true);
|
|
|
|
this.a(new ChatComponentText("Bumm"));
|
2022-02-10 16:28:15 +01:00
|
|
|
this.exploded = true;
|
|
|
|
if (referenceCounter.increment() > 0) {
|
|
|
|
sendEntityDestroy(player);
|
|
|
|
}
|
|
|
|
} else if (referenceCounter.increment() > 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sendEntity(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hide(Player player, boolean force) {
|
|
|
|
if (!force && referenceCounter.decrement() > 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
sendEntityDestroy(player);
|
2022-02-10 17:35:12 +01:00
|
|
|
ag();
|
2022-02-10 16:28:15 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|