当墓碑被解锁时,播放一些特效

This commit is contained in:
2024-12-20 12:20:30 +08:00
parent b49115851b
commit b7412f7ec6

View File

@@ -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<double[]> AC = generateLine(2.5981, 1.5, -2.5981, 1.5, 300);
List<double[]> CE = generateLine(-2.5981, 1.5, 0, -3, 300);
List<double[]> EA = generateLine(0, -3, 2.5981, 1.5, 300);
List<double[]> BD = generateLine(0, 3, -2.5981, -1.5, 300);
List<double[]> DF = generateLine(-2.5981, -1.5, 2.5981, -1.5, 300);
List<double[]> 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<double[]> 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<double[]> 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(