diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java index 420125e..15c7ba9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java @@ -2,10 +2,7 @@ package de.steamwar.bausystem.tracer.show; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.tracer.TNTPosition; -import de.steamwar.bausystem.tracer.show.mode.Advanced; -import de.steamwar.bausystem.tracer.show.mode.AdvancedNoWater; -import de.steamwar.bausystem.tracer.show.mode.Basic; -import de.steamwar.bausystem.tracer.show.mode.BasicNoWater; +import de.steamwar.bausystem.tracer.show.mode.*; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -40,6 +37,9 @@ public class TraceShowManager implements Listener { case "advancednowater": showMode = new AdvancedNoWater(player); break; + case "experimental": + showMode = new Experimental(player); + break; case "basic": case "default": default: diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Experimental.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Experimental.java new file mode 100644 index 0000000..65ebda8 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Experimental.java @@ -0,0 +1,80 @@ +/* + * + * 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 . + * / + */ + +package de.steamwar.bausystem.tracer.show.mode; + +import de.steamwar.bausystem.tracer.*; +import de.steamwar.bausystem.tracer.show.ShowMode; +import de.steamwar.core.Core; +import net.minecraft.server.v1_15_R1.EntityTNTPrimed; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.Map; + +public class Experimental implements ShowMode { + + private final Player player; + + private Map tntEntityMap = new HashMap<>(); + + public Experimental(Player player) { + this.player = player; + } + + @Override + public void show(TNTPosition position) { + RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(position); + if (tntEntityMap.containsKey(roundedTNTPosition)) { + return; + } + + switch (Core.getVersion()) { + case 12: + tntEntityMap.put(roundedTNTPosition, TNTTracer_12.createTNT(player.getWorld(), position, player)); + break; + default: + tntEntityMap.put(roundedTNTPosition, TNTTracer_15.createTNT(player.getWorld(), position, player)); + break; + } + + position = new TNTPosition(position.getLocation().clone().subtract(position.getVelocity().clone().multiply(0.98D / 20))); + + switch (Core.getVersion()) { + case 12: + tntEntityMap.put(roundedTNTPosition, TNTTracer_12.createUpdatePoint(player.getWorld(), position, player)); + break; + default: + tntEntityMap.put(roundedTNTPosition, TNTTracer_15.createUpdatePoint(player.getWorld(), position, player)); + break; + } + } + + @Override + public void hide() { + tntEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> { + abstractTraceEntity.hide(player); + abstractTraceEntity.remove(); + }); + tntEntityMap.clear(); + } + +}