From b7412f7ec608e82041d58d1e02b2d500a8e6a794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=BB=E9=AD=82=E5=9C=A3=E4=BD=BF?= Date: Fri, 20 Dec 2024 12:20:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E5=A2=93=E7=A2=91=E8=A2=AB=E8=A7=A3?= =?UTF-8?q?=E9=94=81=E6=97=B6=EF=BC=8C=E6=92=AD=E6=94=BE=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E7=89=B9=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coordinateRecorder/data/PlayerData.java | 71 +++++++++++++++++-- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/src/main/java/ling/coordinateRecorder/data/PlayerData.java b/src/main/java/ling/coordinateRecorder/data/PlayerData.java index 99de317..7e3b6f0 100644 --- a/src/main/java/ling/coordinateRecorder/data/PlayerData.java +++ b/src/main/java/ling/coordinateRecorder/data/PlayerData.java @@ -3,10 +3,7 @@ package ling.coordinateRecorder.data; import ling.coordinateRecorder.CoordinateRecorder; import ling.database.tables.records.LocationnotepadPO; import ling.database.tables.records.PlayersettingsPO; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.entity.Entity; @@ -19,6 +16,7 @@ import org.jooq.Result; import java.math.BigDecimal; import java.sql.SQLException; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -99,9 +97,74 @@ public class PlayerData { persistent.remove(CoordinateRecorder.getTombstoneOwner()); persistent.remove(CoordinateRecorder.getTombstoneOwnerName()); chest.update(); + //绘制六芒星 + playMagic(location); + //播放雷击特效 + world.strikeLightningEffect(location); + //world.playSound(location, Sound.ENTITY_LIGHTNING_BOLT_THUNDER, 1.0f, 1.0f); player.sendMessage("墓碑已解锁!"); } + /// 在给定位置绘制六芒星 + @SuppressWarnings("DuplicatedCode") + public void playMagic(Location base) { + List AC = generateLine(2.5981, 1.5, -2.5981, 1.5, 300); + List CE = generateLine(-2.5981, 1.5, 0, -3, 300); + List EA = generateLine(0, -3, 2.5981, 1.5, 300); + List BD = generateLine(0, 3, -2.5981, -1.5, 300); + List DF = generateLine(-2.5981, -1.5, 2.5981, -1.5, 300); + List FB = generateLine(2.5981, -1.5, 0, 3, 300); + World world = base.getWorld(); + assert world != null; + for (double[] point : AC) { + world.spawnParticle(Particle.HEART, base.add(point[0], 0, point[1]), 1); + base.subtract(point[0], 0, point[1]); + } + for (double[] point : CE) { + world.spawnParticle(Particle.HEART, base.add(point[0], 0, point[1]), 1); + base.subtract(point[0], 0, point[1]); + } + for (double[] point : EA) { + world.spawnParticle(Particle.HEART, base.add(point[0], 0, point[1]), 1); + base.subtract(point[0], 0, point[1]); + } + for (double[] point : BD) { + world.spawnParticle(Particle.HEART, base.add(point[0], 0, point[1]), 1); + base.subtract(point[0], 0, point[1]); + } + for (double[] point : DF) { + world.spawnParticle(Particle.HEART, base.add(point[0], 0, point[1]), 1); + base.subtract(point[0], 0, point[1]); + } + for (double[] point : FB) { + world.spawnParticle(Particle.HEART, base.add(point[0], 0, point[1]), 1); + base.subtract(point[0], 0, point[1]); + } + } + + + /// 线段计算 + public static List generateLine(double startX, double startZ, double endX, double endZ, int resolution) { + double XStep = (endX - startX) / (double) resolution; + // X 方向的「单元」 + double ZStep = (endZ - startZ) / (double) resolution; + // Z 方向的「单元」 + List result = new ArrayList<>(); + for (int i = 0; i <= resolution; i++) { + double[] point = new double[2]; + // {x, z} 这样的数组 + point[0] = startX; + point[1] = startZ; + result.add(point); + // 加入点阵 + startX += XStep; + startZ += ZStep; + // 移动到下一个单元 + + } + return result; + } + protected Record loadPlayerSettingsRecord() throws SQLException { return CoordinateRecorder.getDatabase().getDSL().select().from(PLAYERSETTINGS).where(