Merge branch 'master' into RegionSystem
# Conflicts: # BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java
Dieser Commit ist enthalten in:
Commit
911385a5af
@ -21,12 +21,12 @@ package de.steamwar.bausystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.gui.GuiTraceShow;
|
||||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||||
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
||||||
import de.steamwar.bausystem.tracer.show.StoredRecords;
|
import de.steamwar.bausystem.tracer.show.StoredRecords;
|
||||||
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
||||||
import de.steamwar.bausystem.tracer.show.mode.Advanced;
|
import de.steamwar.bausystem.tracer.show.mode.EntityShowMode;
|
||||||
import de.steamwar.bausystem.tracer.show.mode.Basic;
|
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -39,6 +39,7 @@ public class CommandTrace implements CommandExecutor {
|
|||||||
player.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen");
|
player.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen");
|
||||||
player.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer");
|
player.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer");
|
||||||
player.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart");
|
player.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart");
|
||||||
|
player.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui");
|
||||||
player.sendMessage("§8/§etrace show §8<§edefault§8|§eadvanced§8> §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen");
|
player.sendMessage("§8/§etrace show §8<§edefault§8|§eadvanced§8> §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen");
|
||||||
player.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen");
|
player.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen");
|
||||||
player.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen");
|
player.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen");
|
||||||
@ -88,19 +89,14 @@ public class CommandTrace implements CommandExecutor {
|
|||||||
break;
|
break;
|
||||||
case "show":
|
case "show":
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
TraceShowManager.show(player, new Basic(player, new ShowModeParameter()));
|
TraceShowManager.show(player, new EntityShowMode(player, new ShowModeParameter()));
|
||||||
} else {
|
} else {
|
||||||
ShowModeParameter showModeParameter = ShowModeParameter.parseArguments(args, 2);
|
if (args[1].equalsIgnoreCase("gui")) {
|
||||||
switch (args[1].toLowerCase()) {
|
GuiTraceShow.openGui(player);
|
||||||
case "advanced":
|
return false;
|
||||||
TraceShowManager.show(player, new Advanced(player, showModeParameter));
|
|
||||||
break;
|
|
||||||
case "basic":
|
|
||||||
case "default":
|
|
||||||
default:
|
|
||||||
TraceShowManager.show(player, new Basic(player, showModeParameter));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
ShowModeParameter showModeParameter = ShowModeParameter.parseArguments(args, 1);
|
||||||
|
TraceShowManager.show(player, new EntityShowMode(player, showModeParameter));
|
||||||
}
|
}
|
||||||
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
||||||
break;
|
break;
|
||||||
|
@ -39,9 +39,8 @@ public class CommandTraceTabCompleter implements TabCompleter {
|
|||||||
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() == RecordStatus.IDLE || RecordStateMachine.getRecordStatus() == RecordStatus.IDLE_AUTO), "start"));
|
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() == RecordStatus.IDLE || RecordStateMachine.getRecordStatus() == RecordStatus.IDLE_AUTO), "start"));
|
||||||
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() != RecordStatus.IDLE && RecordStateMachine.getRecordStatus() != RecordStatus.IDLE_AUTO), "stop"));
|
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() != RecordStatus.IDLE && RecordStateMachine.getRecordStatus() != RecordStatus.IDLE_AUTO), "stop"));
|
||||||
tabCompletes.add(new TabComplete((player, args) -> args.length == 1, "toggleauto", "auto", "show", "hide", "delete", "clear"));
|
tabCompletes.add(new TabComplete((player, args) -> args.length == 1, "toggleauto", "auto", "show", "hide", "delete", "clear"));
|
||||||
tabCompletes.add(new TabComplete((player, args) -> args.length == 2 && args[0].equalsIgnoreCase("show"), "basic", "advanced"));
|
tabCompletes.add(new TabComplete((player, args) -> args.length == 2 && args[0].equalsIgnoreCase("show"), "gui", "-interpolate-xz", "-interpolate-y", "-water", "-advanced", "advanced"));
|
||||||
tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && (args[1].equalsIgnoreCase("basic") || args[1].equalsIgnoreCase("advanced")), "-water"));
|
tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && !args[1].equalsIgnoreCase("gui"), "-interpolate-xz", "-interpolate-y", "-water", "-advanced"));
|
||||||
tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && args[1].equalsIgnoreCase("advanced"), "-interpolate-xz", "-interpolate-y"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
126
BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java
Normale Datei
126
BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java
Normale Datei
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
||||||
|
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
||||||
|
import de.steamwar.bausystem.tracer.show.mode.EntityShowMode;
|
||||||
|
import de.steamwar.inventory.SWInventory;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class GuiTraceShow {
|
||||||
|
|
||||||
|
private static final Map<Player, ShowModeParameter> ShowModeParameterMap = new HashMap<>();
|
||||||
|
|
||||||
|
private GuiTraceShow() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void openGui(Player player) {
|
||||||
|
ShowModeParameter playerShowMode = new ShowModeParameter();
|
||||||
|
playerShowMode.setInterpolate_Y(false);
|
||||||
|
playerShowMode.setInterpolate_XZ(false);
|
||||||
|
ShowModeParameterMap.put(player, playerShowMode);
|
||||||
|
|
||||||
|
SWInventory swInventory = new SWInventory(player, 9, "Trace Show GUI");
|
||||||
|
swInventory.addCloseCallback(clickType -> ShowModeParameterMap.remove(player));
|
||||||
|
setActiveShow(player, swInventory);
|
||||||
|
|
||||||
|
SWItem water = new SWItem(Material.TNT, "§eWasser §7Positionen", Arrays.asList("§7Zeigt alles TNT, welches", "§7im Wasser explodiert ist."), false, clickType -> {});
|
||||||
|
swInventory.setItem(5, water);
|
||||||
|
swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, water));
|
||||||
|
|
||||||
|
SWItem interpolateY = new SWItem(Material.QUARTZ_STAIRS, "§eInterpolation §7Y-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der Y-Achse."), false, clickType -> {});
|
||||||
|
swInventory.setItem(6, interpolateY);
|
||||||
|
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY));
|
||||||
|
|
||||||
|
SWItem interpolateXZ = new SWItem(Material.QUARTZ_SLAB, "§eInterpolation §7XZ-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der XZ-Achse."), false, clickType -> {});
|
||||||
|
swInventory.setItem(7, interpolateXZ);
|
||||||
|
swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, interpolateXZ));
|
||||||
|
// Water Bucket (-water)
|
||||||
|
// TNT (-water-exploded)
|
||||||
|
// Quartz_Stair (-interpolate-y)
|
||||||
|
// Quartz_Slab (-interpolate-xz)
|
||||||
|
swInventory.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setActiveShow(Player player, SWInventory swInventory) {
|
||||||
|
if (TraceShowManager.hasActiveShow(player)) {
|
||||||
|
SWItem shown = new SWItem(Material.LIME_CONCRETE, "§aTraces angezeigt", new ArrayList<>(), false, clickType -> {
|
||||||
|
TraceShowManager.hide(player);
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet");
|
||||||
|
setActiveShow(player, swInventory);
|
||||||
|
});
|
||||||
|
swInventory.setItem(1, shown);
|
||||||
|
} else {
|
||||||
|
SWItem hidden = new SWItem(Material.RED_CONCRETE, "§cTraces ausgeblendet", new ArrayList<>(), false, clickType -> {
|
||||||
|
show(player);
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
||||||
|
setActiveShow(player, swInventory);
|
||||||
|
});
|
||||||
|
swInventory.setItem(1, hidden);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void toggleHideTNTinWaterExploded(Player player, SWInventory swInventory, SWItem swItem) {
|
||||||
|
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
|
||||||
|
showModeParameter.setWater(!showModeParameter.isWater());
|
||||||
|
show(player);
|
||||||
|
|
||||||
|
swItem.setEnchanted(showModeParameter.isWater());
|
||||||
|
swInventory.setItem(5, swItem);
|
||||||
|
swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, swItem));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void toggleInterpolateYPosition(Player player, SWInventory swInventory, SWItem swItem) {
|
||||||
|
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
|
||||||
|
showModeParameter.setInterpolate_Y(!showModeParameter.isInterpolate_Y());
|
||||||
|
show(player);
|
||||||
|
|
||||||
|
swItem.setEnchanted(showModeParameter.isInterpolate_Y());
|
||||||
|
swInventory.setItem(6, swItem);
|
||||||
|
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, swItem));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void toggleInterpolateXZPosition(Player player, SWInventory swInventory, SWItem swItem) {
|
||||||
|
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
|
||||||
|
showModeParameter.setInterpolate_XZ(!showModeParameter.isInterpolate_XZ());
|
||||||
|
show(player);
|
||||||
|
|
||||||
|
swItem.setEnchanted(showModeParameter.isInterpolate_XZ());
|
||||||
|
swInventory.setItem(7, swItem);
|
||||||
|
swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, swItem));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void show(Player player) {
|
||||||
|
TraceShowManager.show(player, new EntityShowMode(player, ShowModeParameterMap.get(player)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -24,9 +24,8 @@ package de.steamwar.bausystem.tracer.show;
|
|||||||
public class ShowModeParameter {
|
public class ShowModeParameter {
|
||||||
|
|
||||||
private boolean water = false;
|
private boolean water = false;
|
||||||
private boolean interpolate_SET = false;
|
private boolean interpolate_Y = false;
|
||||||
private boolean interpolate_Y = true;
|
private boolean interpolate_XZ = false;
|
||||||
private boolean interpolate_XZ = true;
|
|
||||||
|
|
||||||
public ShowModeParameter() {
|
public ShowModeParameter() {
|
||||||
|
|
||||||
@ -44,6 +43,22 @@ public class ShowModeParameter {
|
|||||||
return interpolate_XZ;
|
return interpolate_XZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setWater(boolean water) {
|
||||||
|
this.water = water;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterpolate_Y(boolean interpolate_Y) {
|
||||||
|
this.interpolate_Y = interpolate_Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterpolate_XZ(boolean interpolate_XZ) {
|
||||||
|
this.interpolate_XZ = interpolate_XZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAdvanced() {
|
||||||
|
return interpolate_Y || interpolate_XZ;
|
||||||
|
}
|
||||||
|
|
||||||
public static ShowModeParameter parseArguments(String[] args, int index) {
|
public static ShowModeParameter parseArguments(String[] args, int index) {
|
||||||
ShowModeParameter showModeParameter = new ShowModeParameter();
|
ShowModeParameter showModeParameter = new ShowModeParameter();
|
||||||
for (int i = index; i < args.length; i++) {
|
for (int i = index; i < args.length; i++) {
|
||||||
@ -55,12 +70,7 @@ public class ShowModeParameter {
|
|||||||
case "-interpolate-y":
|
case "-interpolate-y":
|
||||||
case "-interpolate_y":
|
case "-interpolate_y":
|
||||||
case "-y":
|
case "-y":
|
||||||
if (showModeParameter.interpolate_SET) {
|
|
||||||
showModeParameter.interpolate_Y = true;
|
showModeParameter.interpolate_Y = true;
|
||||||
} else {
|
|
||||||
showModeParameter.interpolate_XZ = false;
|
|
||||||
showModeParameter.interpolate_SET = true;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "-interpolatex":
|
case "-interpolatex":
|
||||||
case "-interpolate-x":
|
case "-interpolate-x":
|
||||||
@ -74,12 +84,15 @@ public class ShowModeParameter {
|
|||||||
case "-interpolate-xz":
|
case "-interpolate-xz":
|
||||||
case "-interpolate_xz":
|
case "-interpolate_xz":
|
||||||
case "-xz":
|
case "-xz":
|
||||||
if (showModeParameter.interpolate_SET) {
|
|
||||||
showModeParameter.interpolate_XZ = true;
|
showModeParameter.interpolate_XZ = true;
|
||||||
} else {
|
break;
|
||||||
showModeParameter.interpolate_Y = false;
|
case "advanced":
|
||||||
showModeParameter.interpolate_SET = true;
|
case "-advanced":
|
||||||
}
|
case "-a":
|
||||||
|
showModeParameter.interpolate_Y = true;
|
||||||
|
showModeParameter.interpolate_XZ = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,4 +51,9 @@ public class TraceShowManager implements Listener {
|
|||||||
public void onLeave(PlayerQuitEvent event) {
|
public void onLeave(PlayerQuitEvent event) {
|
||||||
showModes.remove(event.getPlayer());
|
showModes.remove(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasActiveShow(Player player) {
|
||||||
|
return showModes.containsKey(player);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* 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.tracer.show.mode;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
|
|
||||||
import de.steamwar.bausystem.tracer.RoundedTNTPosition;
|
|
||||||
import de.steamwar.bausystem.tracer.TNTPosition;
|
|
||||||
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Consumer;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Advanced extends Basic {
|
|
||||||
|
|
||||||
private final Map<RoundedTNTPosition, AbstractTraceEntity> updateEntityMap = new HashMap<>();
|
|
||||||
|
|
||||||
public Advanced(Player player, ShowModeParameter showModeParameter) {
|
|
||||||
super(player, showModeParameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(TNTPosition position) {
|
|
||||||
super.show(position);
|
|
||||||
|
|
||||||
if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) {
|
|
||||||
for(TNTPosition pos : position.getRecord().getPositions()){
|
|
||||||
applyOnPosition(pos, updatePointPosition ->
|
|
||||||
updateEntityMap.computeIfPresent(new RoundedTNTPosition(updatePointPosition), (p, point) -> point.hide(player, false) ? null : point));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
applyOnPosition(position, updatePointPosition ->
|
|
||||||
updateEntityMap.computeIfAbsent(new RoundedTNTPosition(updatePointPosition), pos -> createEntity(updatePointPosition, false))
|
|
||||||
.display(player, position.isExploded()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
super.hide();
|
|
||||||
updateEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
|
||||||
updateEntityMap.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applyOnPosition(TNTPosition position, Consumer<Vector> function){
|
|
||||||
if (position.getPreviousLocation() == null) return;
|
|
||||||
|
|
||||||
if (showModeParameter.isInterpolate_Y()) {
|
|
||||||
Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY());
|
|
||||||
if(!position.getLocation().equals(updatePointY))
|
|
||||||
function.accept(updatePointY);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showModeParameter.isInterpolate_XZ()){
|
|
||||||
Vector movement = position.getLocation().clone().subtract(position.getPreviousLocation());
|
|
||||||
Vector updatePointXZ = Math.abs(movement.getX()) > Math.abs(movement.getZ())
|
|
||||||
? position.getLocation().clone().setZ(position.getPreviousLocation().getZ())
|
|
||||||
: position.getLocation().clone().setX(position.getPreviousLocation().getX());
|
|
||||||
if(!position.getLocation().equals(updatePointXZ))
|
|
||||||
function.accept(updatePointXZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package de.steamwar.bausystem.tracer.show.mode;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.tracer.*;
|
|
||||||
import de.steamwar.bausystem.tracer.show.ShowMode;
|
|
||||||
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
|
||||||
import de.steamwar.core.VersionedCallable;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Basic implements ShowMode {
|
|
||||||
|
|
||||||
protected final Player player;
|
|
||||||
protected final ShowModeParameter showModeParameter;
|
|
||||||
|
|
||||||
private final Map<RoundedTNTPosition, AbstractTraceEntity> tntEntityMap = new HashMap<>();
|
|
||||||
|
|
||||||
public Basic(Player player, ShowModeParameter showModeParameter) {
|
|
||||||
this.player = player;
|
|
||||||
this.showModeParameter = showModeParameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(TNTPosition position) {
|
|
||||||
if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) {
|
|
||||||
for(TNTPosition pos : position.getRecord().getPositions()){
|
|
||||||
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(pos);
|
|
||||||
tntEntityMap.computeIfPresent(roundedTNTPosition, (p, tnt) -> tnt.hide(player, false) ? null : tnt);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(position);
|
|
||||||
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedTNTPosition, pos -> createEntity(position.getLocation(), true));
|
|
||||||
entity.display(player, position.isExploded());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean checkWater(Vector position) {
|
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(player.getWorld(), position), 8),
|
|
||||||
new VersionedCallable<>(() -> TNTTracer_15.inWater(player.getWorld(), position), 14));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected AbstractTraceEntity createEntity(Vector position, boolean tnt) {
|
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.create(player.getWorld(), position, tnt), 8),
|
|
||||||
new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), position, tnt), 14));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
tntEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
|
||||||
tntEntityMap.clear();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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.tracer.show.mode;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.tracer.*;
|
||||||
|
import de.steamwar.bausystem.tracer.show.ShowMode;
|
||||||
|
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
||||||
|
import de.steamwar.core.VersionedCallable;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Consumer;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class EntityShowMode implements ShowMode {
|
||||||
|
|
||||||
|
protected final Player player;
|
||||||
|
protected final ShowModeParameter showModeParameter;
|
||||||
|
|
||||||
|
private final Map<RoundedTNTPosition, AbstractTraceEntity> tntEntityMap = new HashMap<>();
|
||||||
|
private final Map<RoundedTNTPosition, AbstractTraceEntity> updateEntityMap = new HashMap<>();
|
||||||
|
|
||||||
|
public EntityShowMode(Player player, ShowModeParameter showModeParameter) {
|
||||||
|
this.player = player;
|
||||||
|
this.showModeParameter = showModeParameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show(TNTPosition position) {
|
||||||
|
if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) {
|
||||||
|
// Basic
|
||||||
|
for (TNTPosition pos : position.getRecord().getPositions()) {
|
||||||
|
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(pos);
|
||||||
|
tntEntityMap.computeIfPresent(roundedTNTPosition, (p, tnt) -> {
|
||||||
|
return tnt.hide(player, false) ? null : tnt;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Advanced
|
||||||
|
for (TNTPosition pos : position.getRecord().getPositions()) {
|
||||||
|
applyOnPosition(pos, updatePointPosition -> {
|
||||||
|
updateEntityMap.computeIfPresent(new RoundedTNTPosition(updatePointPosition), (p, point) -> {
|
||||||
|
return point.hide(player, false) ? null : point;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(position);
|
||||||
|
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedTNTPosition, pos -> createEntity(position.getLocation(), true));
|
||||||
|
entity.display(player, position.isExploded());
|
||||||
|
|
||||||
|
applyOnPosition(position, updatePointPosition -> {
|
||||||
|
updateEntityMap.computeIfAbsent(new RoundedTNTPosition(updatePointPosition), pos -> {
|
||||||
|
return createEntity(updatePointPosition, false);
|
||||||
|
}).display(player, position.isExploded());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkWater(Vector position) {
|
||||||
|
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(player.getWorld(), position), 8),
|
||||||
|
new VersionedCallable<>(() -> TNTTracer_15.inWater(player.getWorld(), position), 14));
|
||||||
|
}
|
||||||
|
|
||||||
|
private AbstractTraceEntity createEntity(Vector position, boolean tnt) {
|
||||||
|
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.create(player.getWorld(), position, tnt), 8),
|
||||||
|
new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), position, tnt), 14));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyOnPosition(TNTPosition position, Consumer<Vector> function) {
|
||||||
|
if (position.getPreviousLocation() == null) return;
|
||||||
|
|
||||||
|
if (showModeParameter.isInterpolate_Y()) {
|
||||||
|
Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY());
|
||||||
|
if (!position.getLocation().equals(updatePointY)) {
|
||||||
|
function.accept(updatePointY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showModeParameter.isInterpolate_XZ()) {
|
||||||
|
Vector movement = position.getLocation().clone().subtract(position.getPreviousLocation());
|
||||||
|
Vector updatePointXZ = Math.abs(movement.getX()) > Math.abs(movement.getZ())
|
||||||
|
? position.getLocation().clone().setZ(position.getPreviousLocation().getZ())
|
||||||
|
: position.getLocation().clone().setX(position.getPreviousLocation().getX());
|
||||||
|
if (!position.getLocation().equals(updatePointXZ)) {
|
||||||
|
function.accept(updatePointXZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
tntEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
||||||
|
tntEntityMap.clear();
|
||||||
|
updateEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
||||||
|
updateEntityMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren