Compare commits
No commits in common. "c163885345dad6a8bfb38c4f913ba2b043965b22" and "1caef4bb83796914d500b733fc338ed9114d9fe5" have entirely different histories.
c163885345
...
1caef4bb83
|
|
@ -36,18 +36,6 @@ tasks {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
// Cosmos
|
||||
compileOnly("com.alttd.cosmos:cosmos-api:1.21.6-R0.1-SNAPSHOT") {
|
||||
isChanging = true
|
||||
}
|
||||
// Lombok
|
||||
compileOnly("org.projectlombok:lombok:1.18.32")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
||||
// Premium vanish
|
||||
compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.LeonMangler:PremiumVanishAPI:2.9.0-4")
|
||||
// Jackson/Dynamic Beans Integration
|
||||
implementation("com.fasterxml.jackson.module:jackson-module-parameter-names:2.15.2")
|
||||
// Jackson for JSON Parsing
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind:2.15.2")
|
||||
implementation("com.fasterxml.jackson.core:jackson-annotations:2.15.2")
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@ import com.alttd.commands.subcommands.CommandHelp;
|
|||
import com.alttd.commands.subcommands.CommandReload;
|
||||
import com.alttd.config.Config;
|
||||
import com.alttd.util.Logger;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.command.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
|
@ -16,7 +15,6 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
public class CommandManager implements CommandExecutor, TabExecutor {
|
||||
private final List<SubCommand> subCommands;
|
||||
|
||||
|
|
@ -47,7 +45,7 @@ public class CommandManager implements CommandExecutor, TabExecutor {
|
|||
subCommand = getSubCommand(args[0]);
|
||||
|
||||
if (!commandSender.hasPermission(subCommand.getPermission())) {
|
||||
commandSender.sendRichMessage(Config.NO_PERMISSION);
|
||||
commandSender.sendMiniMessage(Config.NO_PERMISSION, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +61,7 @@ public class CommandManager implements CommandExecutor, TabExecutor {
|
|||
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
||||
.map(SubCommand::getName)
|
||||
.filter(name -> args.length == 0 || name.startsWith(args[0]))
|
||||
.toList()
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
} else {
|
||||
SubCommand subCommand = getSubCommand(args[0]);
|
||||
|
|
@ -73,10 +71,14 @@ public class CommandManager implements CommandExecutor, TabExecutor {
|
|||
return res;
|
||||
}
|
||||
|
||||
public List<SubCommand> getSubCommands() {
|
||||
return subCommands;
|
||||
}
|
||||
|
||||
private SubCommand getSubCommand(String cmdName) {
|
||||
return subCommands.stream()
|
||||
.filter(subCommand -> subCommand.getName().equals(cmdName))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ public class CommandGUI extends SubCommand {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||
if (!(commandSender instanceof Player player)) {
|
||||
commandSender.sendRichMessage(Config.NO_CONSOLE);
|
||||
commandSender.sendMiniMessage(Config.NO_CONSOLE, null);
|
||||
return true;
|
||||
}
|
||||
new OpenParticleGUI(player).open(player);
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ public class CommandHelp extends SubCommand {
|
|||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||
commandSender.sendRichMessage(Config.HELP_MESSAGE_WRAPPER.replaceAll("<commands>", commandManager
|
||||
commandSender.sendMiniMessage(Config.HELP_MESSAGE_WRAPPER.replaceAll("<commands>", commandManager
|
||||
.getSubCommands().stream()
|
||||
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
||||
.map(SubCommand::getHelpMessage)
|
||||
.collect(Collectors.joining("\n"))));
|
||||
.collect(Collectors.joining("\n"))), null);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class CommandReload extends SubCommand {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||
AltitudeParticles.getInstance().reload();
|
||||
commandSender.sendRichMessage("<green>Reloaded AltitudeParticles config.</green>");
|
||||
commandSender.sendMiniMessage("<green>Reloaded AltitudeParticles config.</green>", null);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,33 +1,36 @@
|
|||
package com.alttd.config;
|
||||
|
||||
import com.alttd.models.ParticleData;
|
||||
import com.alttd.models.ParticleInfo;
|
||||
|
||||
import com.alttd.objects.APartType;
|
||||
import com.alttd.objects.AParticle;
|
||||
import com.alttd.objects.Frame;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.ParticleStorage;
|
||||
import com.alttd.util.Logger;
|
||||
import com.destroystokyo.paper.ParticleBuilder;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HexFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ParticleConfig {
|
||||
|
||||
private static final File particlesDir = new File(File.separator + "mnt" + File.separator + "configs"
|
||||
+ File.separator + "AltitudeParticles" + File.separator + "particles");
|
||||
private static ParticleConfig instance = null;
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
private static ParticleConfig getInstance() {
|
||||
if (instance == null)
|
||||
|
|
@ -57,31 +60,34 @@ public class ParticleConfig {
|
|||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a ParticleData object to a ParticleSet
|
||||
* @param particleData The ParticleData object to convert
|
||||
* @return A ParticleSet created from the ParticleData
|
||||
*/
|
||||
public ParticleSet convertToParticleSet(ParticleData particleData) {
|
||||
public ParticleSet loadParticle(JSONObject jsonObject) throws Exception {
|
||||
String particleName = (String) jsonObject.get("particle_name");
|
||||
String displayName = (String) jsonObject.get("display_name");
|
||||
APartType aPartType = APartType.valueOf((String) jsonObject.get("particle_type"));
|
||||
String lore = (String) jsonObject.get("lore");
|
||||
ItemStack displayItem = new ItemStack(Material.valueOf((String) jsonObject.get("display_item")));
|
||||
String permission = (String) jsonObject.get("permission");
|
||||
String packagePermission = (String) jsonObject.get("package_permission");
|
||||
int frameDelay = (int) (long) jsonObject.get("frame_delay");
|
||||
int repeat = (int) (long) jsonObject.get("repeat");
|
||||
int repeatDelay = (int) (long) jsonObject.get("repeat_delay");
|
||||
double randomOffset = (double) jsonObject.get("random_offset");
|
||||
boolean stationary = (boolean) jsonObject.get("stationary");
|
||||
JSONObject frames = (JSONObject) jsonObject.get("frames");
|
||||
List<Frame> loadedFrames = new ArrayList<>();
|
||||
double randomOffset = particleData.getRandomOffset();
|
||||
|
||||
// Process each frame
|
||||
for (Map.Entry<String, List<ParticleInfo>> entry : particleData.getFrames().entrySet()) {
|
||||
for (Object key : frames.keySet()) {
|
||||
Object o = frames.get(key);
|
||||
List<AParticle> aParticleList = new ArrayList<>();
|
||||
for (Object o1 : ((JSONArray) o)) {
|
||||
JSONObject pData = (JSONObject) o1;
|
||||
Particle particleType = Particle.valueOf((String) pData.get("particle_type"));
|
||||
|
||||
// Process each particle in the frame
|
||||
for (ParticleInfo particleInfo : entry.getValue()) {
|
||||
Particle particleType = Particle.valueOf(particleInfo.getParticleType());
|
||||
double x = particleInfo.getX();
|
||||
double y = particleInfo.getY();
|
||||
double z = particleInfo.getZ();
|
||||
|
||||
double x = (double) pData.get("x");
|
||||
double y = (double) pData.get("y");
|
||||
double z = (double) pData.get("z");
|
||||
ParticleBuilder particleBuilder = new ParticleBuilder(particleType);
|
||||
|
||||
// Handle different particle data types
|
||||
if (particleType.getDataType().equals(Particle.DustOptions.class) && particleInfo.getColor() != null) {
|
||||
int rgb = HexFormat.fromHexDigits(particleInfo.getColor());
|
||||
if (particleType.getDataType().equals(Particle.DustOptions.class)) {
|
||||
int rgb = HexFormat.fromHexDigits((String) pData.get("color"));
|
||||
particleBuilder.data(new Particle.DustOptions(Color.fromRGB(rgb), 1));
|
||||
}
|
||||
// else if (particleType.getDataType().equals(MaterialData.class)) {
|
||||
|
|
@ -97,50 +103,38 @@ public class ParticleConfig {
|
|||
//TODO implement
|
||||
} else if (particleType.getDataType().equals(ItemStack.class)) {
|
||||
//TODO implement
|
||||
} else if (particleInfo.getExtra() != null) {
|
||||
particleBuilder.extra(particleInfo.getExtra());
|
||||
} else {
|
||||
double data = (double) pData.get("extra");
|
||||
particleBuilder.extra(data);
|
||||
}
|
||||
|
||||
aParticleList.add(new AParticle(x, y, z, randomOffset, particleBuilder));
|
||||
}
|
||||
|
||||
loadedFrames.add(new Frame(aParticleList));
|
||||
}
|
||||
|
||||
// Create and return the ParticleSet
|
||||
ItemStack displayItem = new ItemStack(Material.valueOf(particleData.getDisplayItem()));
|
||||
return new ParticleSet(
|
||||
loadedFrames,
|
||||
particleData.getDisplayName(),
|
||||
List.of(particleData.getLore().split("\n")),
|
||||
particleData.getFrameDelay(),
|
||||
particleData.getRepeat(),
|
||||
particleData.getRepeatDelay(),
|
||||
particleData.isStationary(),
|
||||
particleData.getAPartType(),
|
||||
particleData.getParticleName(),
|
||||
particleData.getPermission(),
|
||||
particleData.getPackagePermission(),
|
||||
displayItem
|
||||
);
|
||||
return new ParticleSet(loadedFrames, displayName, List.of(lore.split("\n")), frameDelay, repeat, repeatDelay, stationary, aPartType, particleName, permission, packagePermission, displayItem);
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
ParticleStorage.clear();
|
||||
ParticleConfig instance = getInstance();
|
||||
|
||||
for (File file : instance.getJsonFiles()) {
|
||||
JSONParser parser = new JSONParser();
|
||||
try {
|
||||
ParticleData particleData = objectMapper.readValue(file, ParticleData.class);
|
||||
|
||||
ParticleSet particleSet = instance.convertToParticleSet(particleData);
|
||||
|
||||
Object obj = parser.parse(new FileReader(file));
|
||||
ParticleSet particleSet = instance.loadParticle((JSONObject) obj);
|
||||
ParticleStorage.addParticleSet(particleSet.getAPartType(), particleSet);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
Logger.error("Error reading particle file " + file.getName(), e);
|
||||
e.printStackTrace();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception exception) {
|
||||
Logger.error("Error processing particle file " + file.getName(), exception);
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO implement
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,19 @@
|
|||
package com.alttd.listeners;
|
||||
|
||||
import com.alttd.AltitudeParticles;
|
||||
import com.alttd.objects.APartType;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.PlayerSettings;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BlockBreakListener implements Listener {
|
||||
|
||||
|
|
@ -20,7 +27,21 @@ public class BlockBreakListener implements Listener {
|
|||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, event.getPlayer(), () ->
|
||||
event.getBlock().getLocation());
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
|
||||
if (!playerSettings.hasActiveParticles())
|
||||
return;
|
||||
particlesToActivate.forEach(aPartType -> {
|
||||
ParticleSet particleSet = playerSettings.getParticles(aPartType);
|
||||
if (particleSet == null)
|
||||
return;
|
||||
particleSet.run(event.getBlock().getLocation(), player);
|
||||
});
|
||||
}
|
||||
}.runTaskAsynchronously(AltitudeParticles.getInstance());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,19 @@
|
|||
package com.alttd.listeners;
|
||||
|
||||
import com.alttd.AltitudeParticles;
|
||||
import com.alttd.objects.APartType;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.PlayerSettings;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BlockPlaceListener implements Listener {
|
||||
|
||||
|
|
@ -20,7 +27,21 @@ public class BlockPlaceListener implements Listener {
|
|||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, event.getPlayer(), () ->
|
||||
event.getBlock().getLocation());
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
|
||||
if (!playerSettings.hasActiveParticles())
|
||||
return;
|
||||
particlesToActivate.forEach(aPartType -> {
|
||||
ParticleSet particleSet = playerSettings.getParticles(aPartType);
|
||||
if (particleSet == null)
|
||||
return;
|
||||
particleSet.run(event.getBlock().getLocation(), player);
|
||||
});
|
||||
}
|
||||
}.runTaskAsynchronously(AltitudeParticles.getInstance());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
package com.alttd.listeners;
|
||||
|
||||
import com.alttd.AltitudeParticles;
|
||||
import com.alttd.objects.APartType;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.PlayerSettings;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DeathListener implements Listener {
|
||||
|
||||
|
|
@ -21,7 +26,21 @@ public class DeathListener implements Listener {
|
|||
public void onDeath(PlayerDeathEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
Player player = event.getPlayer();
|
||||
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, player, player::getLocation);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
|
||||
if (!playerSettings.hasActiveParticles())
|
||||
return;
|
||||
particlesToActivate.forEach(aPartType -> {
|
||||
ParticleSet particleSet = playerSettings.getParticles(aPartType);
|
||||
if (particleSet == null)
|
||||
return;
|
||||
particleSet.run(player.getLocation(), player);
|
||||
});
|
||||
}
|
||||
}.runTaskAsynchronously(AltitudeParticles.getInstance());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,19 @@
|
|||
package com.alttd.listeners;
|
||||
|
||||
import com.alttd.AltitudeParticles;
|
||||
import com.alttd.objects.APartType;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.PlayerSettings;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class KillListener implements Listener {
|
||||
private final List<APartType> particlesToActivate;
|
||||
|
|
@ -23,6 +29,20 @@ public class KillListener implements Listener {
|
|||
Player player = event.getEntity().getKiller();
|
||||
if (player == null)
|
||||
return;
|
||||
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, player, () -> event.getEntity().getLocation());
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UUID uuid = player.getUniqueId();
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
|
||||
if (!playerSettings.hasActiveParticles())
|
||||
return;
|
||||
particlesToActivate.forEach(aPartType -> {
|
||||
ParticleSet particleSet = playerSettings.getParticles(aPartType);
|
||||
if (particleSet == null)
|
||||
return;
|
||||
particleSet.run(event.getEntity().getLocation(), player);
|
||||
});
|
||||
}
|
||||
}.runTaskAsynchronously(AltitudeParticles.getInstance());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||
public class PlayerQuitListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(PlayerQuitEvent event) { //TODO particles when a player leaves
|
||||
public void onPlayerLeave(PlayerQuitEvent event) {
|
||||
PlayerSettings.removePlayer(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package com.alttd.listeners;
|
||||
|
||||
import com.alttd.AltitudeParticles;
|
||||
import com.alttd.objects.APartType;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.PlayerSettings;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -11,8 +14,10 @@ import org.bukkit.event.block.Action;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class RightClickListener implements Listener {
|
||||
|
||||
|
|
@ -33,7 +38,22 @@ public class RightClickListener implements Listener {
|
|||
Block clickedBlock = event.getClickedBlock();
|
||||
if (clickedBlock == null)
|
||||
return;
|
||||
Player player = event.getPlayer();
|
||||
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, player, player::getLocation);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
|
||||
if (!playerSettings.hasActiveParticles())
|
||||
return;
|
||||
particlesToActivate.forEach(aPartType -> {
|
||||
ParticleSet particleSet = playerSettings.getParticles(aPartType);
|
||||
if (particleSet == null)
|
||||
return;
|
||||
particleSet.run(player.getLocation(), player);
|
||||
});
|
||||
}
|
||||
}.runTaskAsynchronously(AltitudeParticles.getInstance());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
package com.alttd.listeners;
|
||||
|
||||
import com.alttd.AltitudeParticles;
|
||||
import com.alttd.objects.APartType;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.PlayerSettings;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpawnParticleUtil {
|
||||
|
||||
@FunctionalInterface
|
||||
public interface LocationConsumer {
|
||||
Location getLocation();
|
||||
}
|
||||
|
||||
public static void spawnAsyncParticles(List<APartType> particlesToActivate, Player player, LocationConsumer locationConsumer) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
spawn(particlesToActivate, player, locationConsumer);
|
||||
}
|
||||
}.runTaskAsynchronously(AltitudeParticles.getInstance());
|
||||
}
|
||||
|
||||
private static void spawn(List<APartType> particlesToActivate, Player player, LocationConsumer locationConsumer) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
|
||||
if (!playerSettings.hasActiveParticles())
|
||||
return;
|
||||
particlesToActivate.forEach(aPartType -> {
|
||||
ParticleSet particleSet = playerSettings.getParticles(aPartType);
|
||||
if (particleSet == null)
|
||||
return;
|
||||
particleSet.run(locationConsumer.getLocation(), player);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +1,19 @@
|
|||
package com.alttd.listeners;
|
||||
|
||||
import com.alttd.AltitudeParticles;
|
||||
import com.alttd.objects.APartType;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.PlayerSettings;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TeleportArriveListener implements Listener {
|
||||
private final List<APartType> particlesToActivate;
|
||||
|
|
@ -19,7 +26,22 @@ public class TeleportArriveListener implements Listener {
|
|||
public void onTeleportArrive(PlayerTeleportEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, event.getPlayer(), event::getTo);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
|
||||
if (!playerSettings.hasActiveParticles())
|
||||
return;
|
||||
particlesToActivate.forEach(aPartType -> {
|
||||
ParticleSet particleSet = playerSettings.getParticles(aPartType);
|
||||
if (particleSet == null)
|
||||
return;
|
||||
particleSet.run(event.getTo(), player);
|
||||
});
|
||||
}
|
||||
}.runTaskAsynchronously(AltitudeParticles.getInstance());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,77 +0,0 @@
|
|||
package com.alttd.models;
|
||||
|
||||
import com.alttd.objects.APartType;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents the configuration data for a particle effect, including its name, type, display properties,
|
||||
* animations, and permissions. This class is primarily used for managing particle data in the context
|
||||
* of custom particle effects and animations.
|
||||
* <p>
|
||||
* Fields:
|
||||
* - particleName: The unique name of the particle effect, used internally.
|
||||
* - displayName: The name displayed to the user.
|
||||
* - particleType: The type of the particle effect, which corresponds to an {@link APartType}.
|
||||
* - lore: Additional descriptive text associated with the particle effect.
|
||||
* - displayItem: An item representation for display purposes in order to visually represent the effect.
|
||||
* - permission: The permission string required for accessing the particle effect.
|
||||
* - packagePermission: A specific permission string linked to a grouped set of effects.
|
||||
* - frameDelay: The delay between animation frames, in milliseconds.
|
||||
* - repeat: The number of times the particle animation should repeat.
|
||||
* - repeatDelay: The delay between repeat executions, in milliseconds.
|
||||
* - randomOffset: A random position offset applied to the particle effect for variances.
|
||||
* - stationary: Determines if the particle effect remains static or follows movement.
|
||||
* - frames: A map defining animation frames for the particle effect. The key is an identifier, and the
|
||||
* value is a list of {@link ParticleInfo} objects representing the frame's particle configuration.
|
||||
* <p>
|
||||
* Methods:
|
||||
* - getAPartType(): Converts the particleType string field into an equivalent {@link APartType} enum value.
|
||||
* This allows for accessing predefined properties of the particle type.
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class ParticleData {
|
||||
@JsonProperty("particle_name")
|
||||
private String particleName;
|
||||
|
||||
@JsonProperty("display_name")
|
||||
private String displayName;
|
||||
|
||||
@JsonProperty("particle_type")
|
||||
private String particleType;
|
||||
|
||||
private String lore;
|
||||
|
||||
@JsonProperty("display_item")
|
||||
private String displayItem;
|
||||
|
||||
private String permission;
|
||||
|
||||
@JsonProperty("package_permission")
|
||||
private String packagePermission;
|
||||
|
||||
@JsonProperty("frame_delay")
|
||||
private int frameDelay;
|
||||
|
||||
private int repeat;
|
||||
|
||||
@JsonProperty("repeat_delay")
|
||||
private int repeatDelay;
|
||||
|
||||
@JsonProperty("random_offset")
|
||||
private double randomOffset;
|
||||
|
||||
private boolean stationary;
|
||||
|
||||
private Map<String, List<ParticleInfo>> frames;
|
||||
|
||||
public APartType getAPartType() {
|
||||
return APartType.valueOf(particleType);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
package com.alttd.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Represents information about a particle, including its type, position, and additional properties.
|
||||
* This class is used to describe the details of individual particles, including support for
|
||||
* particle-specific attributes such as color and extra data.
|
||||
* <p>
|
||||
* Fields:
|
||||
* - particleType: The type of the particle, as defined by its name or identifier.
|
||||
* - x, y, z: Coordinates representing the position of the particle in the 3D space.
|
||||
* - color: A string representing the color of the particle, used primarily for "DustOptions".
|
||||
* - extra: An additional property used for some specific particle types, allowing for further customization.
|
||||
* <p>
|
||||
* The class is annotated for JSON serialization and deserialization using the Jackson library,
|
||||
* ensuring smooth integration with JSON-based configurations.
|
||||
* <p>
|
||||
* This object is used in the context of particle data configurations and animations.
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class ParticleInfo {
|
||||
@JsonProperty("particle_type")
|
||||
private String particleType;
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
|
||||
// For DustOptions
|
||||
private String color;
|
||||
|
||||
// For other particle types
|
||||
private Double extra;
|
||||
|
||||
}
|
||||
|
|
@ -2,8 +2,6 @@ package com.alttd.util;
|
|||
|
||||
import com.alttd.AltitudeParticles;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Logger {
|
||||
|
||||
static private final java.util.logging.Logger logger;
|
||||
|
|
@ -35,8 +33,4 @@ public class Logger {
|
|||
}
|
||||
logger.severe(severe);
|
||||
}
|
||||
|
||||
public static void error(String error, Throwable throwable) {
|
||||
logger.log(Level.SEVERE, error, throwable);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user