|
|
|
@ -6,9 +6,9 @@ import com.sekwah.advancedportals.core.commands.SubCommand;
|
|
|
|
|
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
|
|
|
|
|
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
|
|
|
|
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
|
|
|
|
|
import com.sekwah.advancedportals.core.portal.AdvancedPortal;
|
|
|
|
|
import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
|
|
|
|
import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
|
|
|
|
|
import com.sekwah.advancedportals.core.serializeddata.PlayerTempData;
|
|
|
|
|
import com.sekwah.advancedportals.core.services.PortalServices;
|
|
|
|
|
import com.sekwah.advancedportals.core.services.PortalTempDataServices;
|
|
|
|
|
import com.sekwah.advancedportals.core.tags.activation.NameTag;
|
|
|
|
@ -18,6 +18,8 @@ import com.sekwah.advancedportals.core.util.Lang;
|
|
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.function.BiConsumer;
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This will be different from the old show command and I believe it is 1.16+ till the latest version as of writing this.
|
|
|
|
@ -44,6 +46,17 @@ public class ShowPortalSubCommand implements SubCommand, SubCommand.SubCommandOn
|
|
|
|
|
@Inject
|
|
|
|
|
ConfigRepository config;
|
|
|
|
|
|
|
|
|
|
final Color POS1_COLOR = new Color(0, 255, 0);
|
|
|
|
|
final Color POS2_COLOR = new Color(255, 0, 0);
|
|
|
|
|
|
|
|
|
|
final Color SELECTION_COLOR = new Color(255, 0, 0, 100);
|
|
|
|
|
|
|
|
|
|
final Color OUTLINE_COLOR = new Color(0, 255, 0, 100);
|
|
|
|
|
|
|
|
|
|
final Color TRIGGER_COLOR = new Color(0, 0, 255, 100);
|
|
|
|
|
|
|
|
|
|
final Color TRIGGER_OUTLINE_COLOR = new Color(0, 117, 200, 100);
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCommand(CommandSenderContainer sender, String[] args) {
|
|
|
|
|
if(core.getMcVersion()[1] < 16) {
|
|
|
|
@ -90,17 +103,18 @@ public class ShowPortalSubCommand implements SubCommand, SubCommand.SubCommandOn
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tempData.getPos1() != null && tempData.getPos2() != null) {
|
|
|
|
|
debugVisuals(player, tempData.getPos1(), tempData.getPos2(), SELECTION_COLOR, SHOW_TICKS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(tempData.getPos1() != null) {
|
|
|
|
|
Debug.addMarker(player, tempData.getPos1(), "Pos1", new Color(0, 255, 0), SHOW_TICKS);
|
|
|
|
|
Debug.addMarker(player, tempData.getPos1(), "Pos1", POS1_COLOR, SHOW_TICKS);
|
|
|
|
|
}
|
|
|
|
|
if(tempData.getPos2() != null) {
|
|
|
|
|
Debug.addMarker(player, tempData.getPos2(), "Pos2", new Color(255, 0, 0), SHOW_TICKS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tempData.getPos1() != null && tempData.getPos2() != null) {
|
|
|
|
|
debugPortal(player, tempData.getPos1(), tempData.getPos2(), new Color(255, 0, 0, 100), SHOW_TICKS, true);
|
|
|
|
|
Debug.addMarker(player, tempData.getPos2(), "Pos2", POS2_COLOR, SHOW_TICKS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var world = player.getWorld();
|
|
|
|
|
for (var portal : portalServices.getPortals()) {
|
|
|
|
|
if(portal.isLocationInPortal(player.getLoc(), config.getVisibleRange())) {
|
|
|
|
|
BlockLocation minLoc = portal.getMinLoc();
|
|
|
|
@ -108,8 +122,16 @@ public class ShowPortalSubCommand implements SubCommand, SubCommand.SubCommandOn
|
|
|
|
|
int midX = (minLoc.posX + maxLoc.posX) / 2;
|
|
|
|
|
int midZ = (minLoc.posZ + maxLoc.posZ) / 2;
|
|
|
|
|
BlockLocation midPoint = new BlockLocation(minLoc.worldName, midX, maxLoc.posY, midZ);
|
|
|
|
|
var color = new Color(0, 255, 0, 100);
|
|
|
|
|
debugPortal(player, portal.getMinLoc(), portal.getMaxLoc(), color, 1000, false);
|
|
|
|
|
Color color;
|
|
|
|
|
if(portal.isTriggerBlock(world.getBlock(midPoint))) {
|
|
|
|
|
color = TRIGGER_OUTLINE_COLOR;
|
|
|
|
|
} else {
|
|
|
|
|
if(midPoint.posX == minLoc.posX || midPoint.posX == maxLoc.posX || midPoint.posZ == minLoc.posZ || midPoint.posZ == maxLoc.posZ)
|
|
|
|
|
color = OUTLINE_COLOR;
|
|
|
|
|
else
|
|
|
|
|
color = new Color(0, 0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
debugVisuals(player, portal, OUTLINE_COLOR, 1000, TRIGGER_COLOR);
|
|
|
|
|
Debug.addMarker(player, midPoint, portal.getArgValues(NameTag.TAG_NAME)[0], color, SHOW_TICKS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -117,7 +139,15 @@ public class ShowPortalSubCommand implements SubCommand, SubCommand.SubCommandOn
|
|
|
|
|
}, 1, 20);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void debugPortal(PlayerContainer player, BlockLocation pos1, BlockLocation pos2, Color color, int time, boolean hideCorners) {
|
|
|
|
|
private void debugVisuals(PlayerContainer player, BlockLocation pos1, BlockLocation pos2, Color color, int time) {
|
|
|
|
|
debugVisuals(player, pos1, pos2, color, time, null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void debugVisuals(PlayerContainer player, AdvancedPortal portal, Color color, int time, Color triggerColor) {
|
|
|
|
|
debugVisuals(player, portal.getMinLoc(), portal.getMaxLoc(), color, time, triggerColor, portal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void debugVisuals(PlayerContainer player, BlockLocation pos1, BlockLocation pos2, Color color, int time, Color triggerColor, AdvancedPortal portal) {
|
|
|
|
|
int minX = Math.min(pos1.posX, pos2.posX);
|
|
|
|
|
int minY = Math.min(pos1.posY, pos2.posY);
|
|
|
|
|
int minZ = Math.min(pos1.posZ, pos2.posZ);
|
|
|
|
@ -126,17 +156,54 @@ public class ShowPortalSubCommand implements SubCommand, SubCommand.SubCommandOn
|
|
|
|
|
int maxY = Math.max(pos1.posY, pos2.posY);
|
|
|
|
|
int maxZ = Math.max(pos1.posZ, pos2.posZ);
|
|
|
|
|
|
|
|
|
|
for (int x = minX; x <= maxX; x++) {
|
|
|
|
|
for (int y = minY; y <= maxY; y++) {
|
|
|
|
|
for (int z = minZ; z <= maxZ; z++) {
|
|
|
|
|
if ((y == minY || y == maxY) && (x == minX || x == maxX || z == minZ || z == maxZ) || (z == minZ || z == maxZ) && (x == minX || x == maxX)) {
|
|
|
|
|
var world = player.getWorld();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int widthX = maxX - minX + 1;
|
|
|
|
|
int widthY = maxY - minY + 1;
|
|
|
|
|
int widthZ = maxZ - minZ + 1;
|
|
|
|
|
|
|
|
|
|
int totalBlocks = widthX * widthY * widthZ;
|
|
|
|
|
|
|
|
|
|
if(totalBlocks <= config.getMaxTriggerVisualisationSize()) {
|
|
|
|
|
for (int x = minX; x <= maxX; x++) {
|
|
|
|
|
for (int y = minY; y <= maxY; y++) {
|
|
|
|
|
for (int z = minZ; z <= maxZ; z++) {
|
|
|
|
|
var pos = new BlockLocation(pos1.worldName, x, y, z);
|
|
|
|
|
if ((pos.equals(pos1) || pos.equals(pos2)) && hideCorners)
|
|
|
|
|
continue;
|
|
|
|
|
Debug.addMarker(player, pos, "", color, time);
|
|
|
|
|
boolean isTrigger = portal != null && portal.isTriggerBlock(world.getBlock(pos));
|
|
|
|
|
boolean isOutline = (y == minY || y == maxY) && (x == minX || x == maxX || z == minZ || z == maxZ) || (z == minZ || z == maxZ) && (x == minX || x == maxX);
|
|
|
|
|
if (isTrigger && isOutline) {
|
|
|
|
|
Debug.addMarker(player, pos, "", TRIGGER_OUTLINE_COLOR, time);
|
|
|
|
|
}
|
|
|
|
|
else if(isTrigger) {
|
|
|
|
|
Debug.addMarker(player, pos, "", triggerColor, time);
|
|
|
|
|
} else if (isOutline) {
|
|
|
|
|
Debug.addMarker(player, pos, "", color, time);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
for (int x = minX; x <= maxX; x++) {
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, x, minY, minZ), "", color, time);
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, x, minY, maxZ), "", color, time);
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, x, maxY, minZ), "", color, time);
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, x, maxY, maxZ), "", color, time);
|
|
|
|
|
}
|
|
|
|
|
for (int z = minZ + 1; z < maxZ; z++) {
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, minX, minY, z), "", color, time);
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, maxX, minY, z), "", color, time);
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, minX, maxY, z), "", color, time);
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, maxX, maxY, z), "", color, time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int y = minY + 1; y < maxY; y++) {
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, minX, y, minZ), "", color, time);
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, maxX, y, minZ), "", color, time);
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, minX, y, maxZ), "", color, time);
|
|
|
|
|
Debug.addMarker(player, new BlockLocation(pos1.worldName, maxX, y, maxZ), "", color, time);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|