Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa14d001da | ||
|
|
c163885345 | ||
|
|
95bb1e90fe | ||
|
|
a3b4922b70 |
+14
-2
@@ -36,6 +36,18 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT")
|
// Cosmos
|
||||||
compileOnly("com.github.LeonMangler:PremiumVanishAPI:2.9.0-4")
|
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.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")
|
||||||
}
|
}
|
||||||
@@ -8,17 +8,15 @@ import com.alttd.database.Database;
|
|||||||
import com.alttd.listeners.*;
|
import com.alttd.listeners.*;
|
||||||
import com.alttd.objects.APartType;
|
import com.alttd.objects.APartType;
|
||||||
import com.alttd.util.Logger;
|
import com.alttd.util.Logger;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class AltitudeParticles extends JavaPlugin {
|
public class AltitudeParticles extends JavaPlugin {
|
||||||
|
|
||||||
|
@Getter
|
||||||
public static AltitudeParticles instance;
|
public static AltitudeParticles instance;
|
||||||
|
|
||||||
public static AltitudeParticles getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.alttd.commands.subcommands.CommandHelp;
|
|||||||
import com.alttd.commands.subcommands.CommandReload;
|
import com.alttd.commands.subcommands.CommandReload;
|
||||||
import com.alttd.config.Config;
|
import com.alttd.config.Config;
|
||||||
import com.alttd.util.Logger;
|
import com.alttd.util.Logger;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -13,8 +14,8 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class CommandManager implements CommandExecutor, TabExecutor {
|
public class CommandManager implements CommandExecutor, TabExecutor {
|
||||||
private final List<SubCommand> subCommands;
|
private final List<SubCommand> subCommands;
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ public class CommandManager implements CommandExecutor, TabExecutor {
|
|||||||
subCommand = getSubCommand(args[0]);
|
subCommand = getSubCommand(args[0]);
|
||||||
|
|
||||||
if (!commandSender.hasPermission(subCommand.getPermission())) {
|
if (!commandSender.hasPermission(subCommand.getPermission())) {
|
||||||
commandSender.sendMiniMessage(Config.NO_PERMISSION, null);
|
commandSender.sendRichMessage(Config.NO_PERMISSION);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ public class CommandManager implements CommandExecutor, TabExecutor {
|
|||||||
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
||||||
.map(SubCommand::getName)
|
.map(SubCommand::getName)
|
||||||
.filter(name -> args.length == 0 || name.startsWith(args[0]))
|
.filter(name -> args.length == 0 || name.startsWith(args[0]))
|
||||||
.collect(Collectors.toList())
|
.toList()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
SubCommand subCommand = getSubCommand(args[0]);
|
SubCommand subCommand = getSubCommand(args[0]);
|
||||||
@@ -71,10 +72,6 @@ public class CommandManager implements CommandExecutor, TabExecutor {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SubCommand> getSubCommands() {
|
|
||||||
return subCommands;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SubCommand getSubCommand(String cmdName) {
|
private SubCommand getSubCommand(String cmdName) {
|
||||||
return subCommands.stream()
|
return subCommands.stream()
|
||||||
.filter(subCommand -> subCommand.getName().equals(cmdName))
|
.filter(subCommand -> subCommand.getName().equals(cmdName))
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class CommandGUI extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
if (!(commandSender instanceof Player player)) {
|
if (!(commandSender instanceof Player player)) {
|
||||||
commandSender.sendMiniMessage(Config.NO_CONSOLE, null);
|
commandSender.sendRichMessage(Config.NO_CONSOLE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
new OpenParticleGUI(player).open(player);
|
new OpenParticleGUI(player).open(player);
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ public class CommandHelp extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
commandSender.sendMiniMessage(Config.HELP_MESSAGE_WRAPPER.replaceAll("<commands>", commandManager
|
commandSender.sendRichMessage(Config.HELP_MESSAGE_WRAPPER.replaceAll("<commands>", commandManager
|
||||||
.getSubCommands().stream()
|
.getSubCommands().stream()
|
||||||
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
||||||
.map(SubCommand::getHelpMessage)
|
.map(SubCommand::getHelpMessage)
|
||||||
.collect(Collectors.joining("\n"))), null);
|
.collect(Collectors.joining("\n"))));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package com.alttd.commands.subcommands;
|
|||||||
import com.alttd.AltitudeParticles;
|
import com.alttd.AltitudeParticles;
|
||||||
import com.alttd.commands.SubCommand;
|
import com.alttd.commands.SubCommand;
|
||||||
import com.alttd.config.Config;
|
import com.alttd.config.Config;
|
||||||
import com.alttd.config.DatabaseConfig;
|
|
||||||
import com.alttd.config.ParticleConfig;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -15,7 +13,7 @@ public class CommandReload extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
AltitudeParticles.getInstance().reload();
|
AltitudeParticles.getInstance().reload();
|
||||||
commandSender.sendMiniMessage("<green>Reloaded AltitudeParticles config.</green>", null);
|
commandSender.sendRichMessage("<green>Reloaded AltitudeParticles config.</green>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ abstract class AbstractConfig {
|
|||||||
throw new RuntimeException(ex.getCause());
|
throw new RuntimeException(ex.getCause());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.severe("Error invoking %.", method.toString());
|
Logger.severe("Error invoking %.", method.toString());
|
||||||
ex.printStackTrace();
|
Logger.error("Failed to invoke", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ abstract class AbstractConfig {
|
|||||||
yaml.save(file);
|
yaml.save(file);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.severe("Could not save %.", file.toString());
|
Logger.severe("Could not save %.", file.toString());
|
||||||
ex.printStackTrace();
|
Logger.error("Failed to save", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.alttd.config;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public final class Config extends AbstractConfig {
|
public final class Config extends AbstractConfig {
|
||||||
|
|
||||||
static Config config;
|
static Config config;
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.alttd.config;
|
package com.alttd.config;
|
||||||
|
|
||||||
import com.alttd.database.Database;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class DatabaseConfig extends AbstractConfig {
|
public class DatabaseConfig extends AbstractConfig {
|
||||||
|
|
||||||
static DatabaseConfig config;
|
static DatabaseConfig config;
|
||||||
|
|||||||
@@ -1,36 +1,33 @@
|
|||||||
package com.alttd.config;
|
package com.alttd.config;
|
||||||
|
|
||||||
|
import com.alttd.models.ParticleData;
|
||||||
import com.alttd.objects.APartType;
|
import com.alttd.models.ParticleInfo;
|
||||||
import com.alttd.objects.AParticle;
|
import com.alttd.objects.AParticle;
|
||||||
import com.alttd.objects.Frame;
|
import com.alttd.objects.Frame;
|
||||||
import com.alttd.objects.ParticleSet;
|
import com.alttd.objects.ParticleSet;
|
||||||
import com.alttd.storage.ParticleStorage;
|
import com.alttd.storage.ParticleStorage;
|
||||||
import com.alttd.util.Logger;
|
import com.alttd.util.Logger;
|
||||||
import com.destroystokyo.paper.ParticleBuilder;
|
import com.destroystokyo.paper.ParticleBuilder;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HexFormat;
|
import java.util.HexFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ParticleConfig {
|
public class ParticleConfig {
|
||||||
|
|
||||||
private static final File particlesDir = new File(File.separator + "mnt" + File.separator + "configs"
|
private static final File particlesDir = new File(File.separator + "mnt" + File.separator + "configs"
|
||||||
+ File.separator + "AltitudeParticles" + File.separator + "particles");
|
+ File.separator + "AltitudeParticles" + File.separator + "particles");
|
||||||
private static ParticleConfig instance = null;
|
private static ParticleConfig instance = null;
|
||||||
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
private static ParticleConfig getInstance() {
|
private static ParticleConfig getInstance() {
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
@@ -60,34 +57,31 @@ public class ParticleConfig {
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleSet loadParticle(JSONObject jsonObject) throws Exception {
|
/**
|
||||||
String particleName = (String) jsonObject.get("particle_name");
|
* Converts a ParticleData object to a ParticleSet
|
||||||
String displayName = (String) jsonObject.get("display_name");
|
* @param particleData The ParticleData object to convert
|
||||||
APartType aPartType = APartType.valueOf((String) jsonObject.get("particle_type"));
|
* @return A ParticleSet created from the ParticleData
|
||||||
String lore = (String) jsonObject.get("lore");
|
*/
|
||||||
ItemStack displayItem = new ItemStack(Material.valueOf((String) jsonObject.get("display_item")));
|
public ParticleSet convertToParticleSet(ParticleData particleData) {
|
||||||
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<>();
|
List<Frame> loadedFrames = new ArrayList<>();
|
||||||
for (Object key : frames.keySet()) {
|
double randomOffset = particleData.getRandomOffset();
|
||||||
Object o = frames.get(key);
|
|
||||||
List<AParticle> aParticleList = new ArrayList<>();
|
// Process each frame
|
||||||
for (Object o1 : ((JSONArray) o)) {
|
for (Map.Entry<String, List<ParticleInfo>> entry : particleData.getFrames().entrySet()) {
|
||||||
JSONObject pData = (JSONObject) o1;
|
List<AParticle> aParticleList = new ArrayList<>();
|
||||||
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);
|
ParticleBuilder particleBuilder = new ParticleBuilder(particleType);
|
||||||
if (particleType.getDataType().equals(Particle.DustOptions.class)) {
|
|
||||||
int rgb = HexFormat.fromHexDigits((String) pData.get("color"));
|
// Handle different particle data types
|
||||||
|
if (particleType.getDataType().equals(Particle.DustOptions.class) && particleInfo.getColor() != null) {
|
||||||
|
int rgb = HexFormat.fromHexDigits(particleInfo.getColor());
|
||||||
particleBuilder.data(new Particle.DustOptions(Color.fromRGB(rgb), 1));
|
particleBuilder.data(new Particle.DustOptions(Color.fromRGB(rgb), 1));
|
||||||
}
|
}
|
||||||
// else if (particleType.getDataType().equals(MaterialData.class)) {
|
// else if (particleType.getDataType().equals(MaterialData.class)) {
|
||||||
@@ -103,38 +97,50 @@ public class ParticleConfig {
|
|||||||
//TODO implement
|
//TODO implement
|
||||||
} else if (particleType.getDataType().equals(ItemStack.class)) {
|
} else if (particleType.getDataType().equals(ItemStack.class)) {
|
||||||
//TODO implement
|
//TODO implement
|
||||||
} else {
|
} else if (particleInfo.getExtra() != null) {
|
||||||
double data = (double) pData.get("extra");
|
particleBuilder.extra(particleInfo.getExtra());
|
||||||
particleBuilder.extra(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aParticleList.add(new AParticle(x, y, z, randomOffset, particleBuilder));
|
aParticleList.add(new AParticle(x, y, z, randomOffset, particleBuilder));
|
||||||
}
|
}
|
||||||
|
|
||||||
loadedFrames.add(new Frame(aParticleList));
|
loadedFrames.add(new Frame(aParticleList));
|
||||||
}
|
}
|
||||||
return new ParticleSet(loadedFrames, displayName, List.of(lore.split("\n")), frameDelay, repeat, repeatDelay, stationary, aPartType, particleName, permission, packagePermission, displayItem);
|
|
||||||
|
// 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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload() {
|
public static void reload() {
|
||||||
ParticleStorage.clear();
|
ParticleStorage.clear();
|
||||||
ParticleConfig instance = getInstance();
|
ParticleConfig instance = getInstance();
|
||||||
|
|
||||||
for (File file : instance.getJsonFiles()) {
|
for (File file : instance.getJsonFiles()) {
|
||||||
JSONParser parser = new JSONParser();
|
|
||||||
try {
|
try {
|
||||||
Object obj = parser.parse(new FileReader(file));
|
ParticleData particleData = objectMapper.readValue(file, ParticleData.class);
|
||||||
ParticleSet particleSet = instance.loadParticle((JSONObject) obj);
|
|
||||||
|
ParticleSet particleSet = instance.convertToParticleSet(particleData);
|
||||||
|
|
||||||
ParticleStorage.addParticleSet(particleSet.getAPartType(), particleSet);
|
ParticleStorage.addParticleSet(particleSet.getAPartType(), particleSet);
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Logger.error("Error reading particle file " + file.getName(), e);
|
||||||
} catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
Logger.error("Error processing particle file " + file.getName(), exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO implement
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class Database {
|
|||||||
try {
|
try {
|
||||||
openConnection();
|
openConnection();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error("Unable to open connection", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tables
|
// Tables
|
||||||
@@ -48,7 +48,7 @@ public class Database {
|
|||||||
try {
|
try {
|
||||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
Logger.error("Error while trying to open connection", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
connection = DriverManager.getConnection(
|
connection = DriverManager.getConnection(
|
||||||
@@ -66,7 +66,7 @@ public class Database {
|
|||||||
try {
|
try {
|
||||||
instance.openConnection();
|
instance.openConnection();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Logger.error("Error while trying to get connection", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
@@ -74,15 +74,17 @@ public class Database {
|
|||||||
|
|
||||||
private static void createActiveParticlesTable() {
|
private static void createActiveParticlesTable() {
|
||||||
try {
|
try {
|
||||||
String sql = "CREATE TABLE IF NOT EXISTS active_particles(" +
|
String sql = """
|
||||||
"uuid VARCHAR(36) NOT NULL, " +
|
CREATE TABLE IF NOT EXISTS active_particles(
|
||||||
"particle_type VARCHAR(36) NOT NULL, " +
|
uuid VARCHAR(36) NOT NULL,
|
||||||
"particle_id VARCHAR(36) NOT NULL, " +
|
particle_type VARCHAR(36) NOT NULL,
|
||||||
"PRIMARY KEY (uuid, particle_type)" +
|
particle_id VARCHAR(36) NOT NULL,
|
||||||
")";
|
PRIMARY KEY (uuid, particle_type)
|
||||||
|
)""";
|
||||||
connection.prepareStatement(sql).executeUpdate();
|
connection.prepareStatement(sql).executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error("Error while trying to create user point table", e);
|
||||||
|
|
||||||
Logger.severe("Error while trying to create user point table");
|
Logger.severe("Error while trying to create user point table");
|
||||||
Logger.severe("Shutting down AltitudeParticles");
|
Logger.severe("Shutting down AltitudeParticles");
|
||||||
Bukkit.getPluginManager().disablePlugin(AltitudeParticles.getInstance());
|
Bukkit.getPluginManager().disablePlugin(AltitudeParticles.getInstance());
|
||||||
@@ -91,16 +93,16 @@ public class Database {
|
|||||||
|
|
||||||
private static void createUserSettingsTable() {
|
private static void createUserSettingsTable() {
|
||||||
try {
|
try {
|
||||||
String sql = "CREATE TABLE IF NOT EXISTS user_settings(" +
|
String sql = """
|
||||||
"uuid VARCHAR(36) NOT NULL, " +
|
CREATE TABLE IF NOT EXISTS user_settings(
|
||||||
"particles_active BIT(1) NOT NULL DEFAULT b'1', " +
|
uuid VARCHAR(36) NOT NULL,
|
||||||
"seeing_particles BIT(1) NOT NULL DEFAULT b'1', " +
|
particles_active BIT(1) NOT NULL DEFAULT b'1',
|
||||||
"PRIMARY KEY (uuid)" +
|
seeing_particles BIT(1) NOT NULL DEFAULT b'1',
|
||||||
")";
|
PRIMARY KEY (uuid)
|
||||||
|
)""";
|
||||||
connection.prepareStatement(sql).executeUpdate();
|
connection.prepareStatement(sql).executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error("Error while trying to create user point table", e);
|
||||||
Logger.severe("Error while trying to create user point table");
|
|
||||||
Logger.severe("Shutting down AltitudeParticles");
|
Logger.severe("Shutting down AltitudeParticles");
|
||||||
Bukkit.getPluginManager().disablePlugin(AltitudeParticles.getInstance());
|
Bukkit.getPluginManager().disablePlugin(AltitudeParticles.getInstance());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,44 +16,44 @@ import java.util.UUID;
|
|||||||
public class Queries {
|
public class Queries {
|
||||||
|
|
||||||
public static void setSeeingParticles(UUID uuid, boolean seeingParticles) {
|
public static void setSeeingParticles(UUID uuid, boolean seeingParticles) {
|
||||||
String sql = "UPDATE user_settings " +
|
String sql = """
|
||||||
"SET seeing_particles = ?" +
|
UPDATE user_settings
|
||||||
"WHERE uuid = ?";
|
SET seeing_particles = ?
|
||||||
|
WHERE uuid = ?""";
|
||||||
|
|
||||||
try {
|
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
|
||||||
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
|
|
||||||
preparedStatement.setInt(1, seeingParticles ? 1 : 0);
|
preparedStatement.setInt(1, seeingParticles ? 1 : 0);
|
||||||
preparedStatement.setString(2, uuid.toString());
|
preparedStatement.setString(2, uuid.toString());
|
||||||
|
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error(String.format("unable to set seeing particles for %s", uuid.toString()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setParticlesActive(UUID uuid, boolean particlesActive) {
|
public static void setParticlesActive(UUID uuid, boolean particlesActive) {
|
||||||
String sql = "UPDATE user_settings " +
|
String sql = """
|
||||||
"SET particles_active = ? " +
|
UPDATE user_settings
|
||||||
"WHERE uuid = ?";
|
SET particles_active = ?
|
||||||
|
WHERE uuid = ?""";
|
||||||
|
|
||||||
try {
|
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
|
||||||
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
|
|
||||||
preparedStatement.setInt(1, particlesActive ? 1 : 0);
|
preparedStatement.setInt(1, particlesActive ? 1 : 0);
|
||||||
preparedStatement.setString(2, uuid.toString());
|
preparedStatement.setString(2, uuid.toString());
|
||||||
|
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error(String.format("unable to set particles for %s", uuid.toString()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addParticle(UUID uuid, APartType aPartType, String particleId) {
|
public static void addParticle(UUID uuid, APartType aPartType, String particleId) {
|
||||||
String sql = "INSERT INTO active_particles (uuid, particle_type, particle_id) " +
|
String sql = """
|
||||||
"VALUES (?, ?, ?) " +
|
INSERT INTO active_particles (uuid, particle_type, particle_id)
|
||||||
"ON DUPLICATE KEY UPDATE particle_id = ?";
|
VALUES (?, ?, ?)
|
||||||
|
ON DUPLICATE KEY UPDATE particle_id = ?""";
|
||||||
|
|
||||||
try {
|
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
|
||||||
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
|
|
||||||
preparedStatement.setString(1, uuid.toString());
|
preparedStatement.setString(1, uuid.toString());
|
||||||
preparedStatement.setString(2, aPartType.getName());
|
preparedStatement.setString(2, aPartType.getName());
|
||||||
preparedStatement.setString(3, particleId);
|
preparedStatement.setString(3, particleId);
|
||||||
@@ -61,43 +61,45 @@ public class Queries {
|
|||||||
|
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error(String.format("unable to add particle for %s", uuid.toString()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeParticle(UUID uuid, APartType aPartType) {
|
public static void removeParticle(UUID uuid, APartType aPartType) {
|
||||||
String sql = "DELETE FROM active_particles " +
|
String sql = """
|
||||||
"WHERE uuid = ? " +
|
DELETE FROM active_particles
|
||||||
"AND particle_type = ?";
|
WHERE uuid = ?
|
||||||
|
AND particle_type = ?""";
|
||||||
|
|
||||||
try {
|
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
|
||||||
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
|
|
||||||
preparedStatement.setString(1, uuid.toString());
|
preparedStatement.setString(1, uuid.toString());
|
||||||
preparedStatement.setString(2, aPartType.getName());
|
preparedStatement.setString(2, aPartType.getName());
|
||||||
|
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error(String.format("unable to remove particles for %s", uuid.toString()), e);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearParticles(UUID uuid) {
|
public static void clearParticles(UUID uuid) {
|
||||||
String sql = "DELETE FROM active_particles " +
|
String sql = """
|
||||||
"WHERE uuid = ?";
|
DELETE FROM active_particles
|
||||||
try {
|
WHERE uuid = ?""";
|
||||||
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
|
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
|
||||||
preparedStatement.setString(1, uuid.toString());
|
preparedStatement.setString(1, uuid.toString());
|
||||||
|
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error(String.format("unable to clear particles for %s", uuid.toString()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerSettings getPlayerSettings(UUID uuid) {
|
public static PlayerSettings getPlayerSettings(UUID uuid) {
|
||||||
String sql = "SELECT * FROM user_settings WHERE uuid = ?";
|
String sql = """
|
||||||
try {
|
SELECT * FROM user_settings
|
||||||
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
|
WHERE uuid = ?""";
|
||||||
|
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
|
||||||
preparedStatement.setString(1, uuid.toString());
|
preparedStatement.setString(1, uuid.toString());
|
||||||
|
|
||||||
ResultSet resultSet = preparedStatement.executeQuery();
|
ResultSet resultSet = preparedStatement.executeQuery();
|
||||||
@@ -109,18 +111,18 @@ public class Queries {
|
|||||||
return new PlayerSettings(particlesActive, seeingParticles, uuid, activeParticles);
|
return new PlayerSettings(particlesActive, seeingParticles, uuid, activeParticles);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error(String.format("unable to get player settings for %s", uuid.toString()), e);
|
||||||
}
|
}
|
||||||
return createNewPlayerSettings(uuid);
|
return createNewPlayerSettings(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<APartType, ParticleSet> getActiveParticles(UUID uuid) {
|
private static HashMap<APartType, ParticleSet> getActiveParticles(UUID uuid) {
|
||||||
HashMap<APartType, ParticleSet> activeParticles = new HashMap<>();
|
HashMap<APartType, ParticleSet> activeParticles = new HashMap<>();
|
||||||
String sql = "SELECT * FROM active_particles " +
|
String sql = """
|
||||||
"WHERE uuid = ?";
|
SELECT * FROM active_particles
|
||||||
|
WHERE uuid = ?""";
|
||||||
|
|
||||||
try {
|
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
|
||||||
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
|
|
||||||
preparedStatement.setString(1, uuid.toString());
|
preparedStatement.setString(1, uuid.toString());
|
||||||
|
|
||||||
ResultSet resultSet = preparedStatement.executeQuery();
|
ResultSet resultSet = preparedStatement.executeQuery();
|
||||||
@@ -145,19 +147,19 @@ public class Queries {
|
|||||||
activeParticles.put(aPartType, first.get());
|
activeParticles.put(aPartType, first.get());
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error(String.format("unable to get player settings for %s", uuid.toString()), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return activeParticles;
|
return activeParticles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PlayerSettings createNewPlayerSettings(UUID uuid) {
|
private static PlayerSettings createNewPlayerSettings(UUID uuid) {
|
||||||
String sql = "INSERT INTO user_settings (uuid, particles_active, seeing_particles)" +
|
String sql = """
|
||||||
"VALUES (?, ?, ?)" +
|
INSERT INTO user_settings (uuid, particles_active, seeing_particles)
|
||||||
"ON DUPLICATE KEY UPDATE particles_active = ?, seeing_particles = ?";
|
VALUES (?, ?, ?)
|
||||||
|
ON DUPLICATE KEY UPDATE particles_active = ?, seeing_particles = ?""";
|
||||||
|
|
||||||
try {
|
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
|
||||||
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
|
|
||||||
preparedStatement.setString(1, uuid.toString());
|
preparedStatement.setString(1, uuid.toString());
|
||||||
preparedStatement.setInt(2, 1);
|
preparedStatement.setInt(2, 1);
|
||||||
preparedStatement.setInt(3, 1);
|
preparedStatement.setInt(3, 1);
|
||||||
@@ -166,7 +168,7 @@ public class Queries {
|
|||||||
|
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.error(String.format("unable to get player settings for %s", uuid.toString()), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PlayerSettings(true, true, uuid);
|
return new PlayerSettings(true, true, uuid);
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ChooseParticleGUI extends DefaultGUI {
|
public class ChooseParticleGUI extends DefaultGUI {
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ public class ChooseParticleGUI extends DefaultGUI {
|
|||||||
super(name);
|
super(name);
|
||||||
List<ParticleSet> availableParticles = ParticleStorage.getParticleSets(aPartType).stream()
|
List<ParticleSet> availableParticles = ParticleStorage.getParticleSets(aPartType).stream()
|
||||||
.filter(particleSet -> player.hasPermission(particleSet.getPackPermission()) || player.hasPermission(particleSet.getPermission()))
|
.filter(particleSet -> player.hasPermission(particleSet.getPackPermission()) || player.hasPermission(particleSet.getPermission()))
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());
|
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ParticleSet particleSet : availableParticles) {
|
for (ParticleSet particleSet : availableParticles) {
|
||||||
|
|||||||
@@ -1,19 +1,12 @@
|
|||||||
package com.alttd.listeners;
|
package com.alttd.listeners;
|
||||||
|
|
||||||
import com.alttd.AltitudeParticles;
|
|
||||||
import com.alttd.objects.APartType;
|
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.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class BlockBreakListener implements Listener {
|
public class BlockBreakListener implements Listener {
|
||||||
|
|
||||||
@@ -27,21 +20,7 @@ public class BlockBreakListener implements Listener {
|
|||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
new BukkitRunnable() {
|
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, event.getPlayer(), () ->
|
||||||
@Override
|
event.getBlock().getLocation());
|
||||||
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,19 +1,12 @@
|
|||||||
package com.alttd.listeners;
|
package com.alttd.listeners;
|
||||||
|
|
||||||
import com.alttd.AltitudeParticles;
|
|
||||||
import com.alttd.objects.APartType;
|
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.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class BlockPlaceListener implements Listener {
|
public class BlockPlaceListener implements Listener {
|
||||||
|
|
||||||
@@ -27,21 +20,7 @@ public class BlockPlaceListener implements Listener {
|
|||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
new BukkitRunnable() {
|
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, event.getPlayer(), () ->
|
||||||
@Override
|
event.getBlock().getLocation());
|
||||||
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,18 +1,13 @@
|
|||||||
package com.alttd.listeners;
|
package com.alttd.listeners;
|
||||||
|
|
||||||
import com.alttd.AltitudeParticles;
|
|
||||||
import com.alttd.objects.APartType;
|
import com.alttd.objects.APartType;
|
||||||
import com.alttd.objects.ParticleSet;
|
|
||||||
import com.alttd.storage.PlayerSettings;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class DeathListener implements Listener {
|
public class DeathListener implements Listener {
|
||||||
|
|
||||||
@@ -26,21 +21,7 @@ public class DeathListener implements Listener {
|
|||||||
public void onDeath(PlayerDeathEvent event) {
|
public void onDeath(PlayerDeathEvent event) {
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UUID uuid = player.getUniqueId();
|
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, player, player::getLocation);
|
||||||
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,19 +1,13 @@
|
|||||||
package com.alttd.listeners;
|
package com.alttd.listeners;
|
||||||
|
|
||||||
import com.alttd.AltitudeParticles;
|
|
||||||
import com.alttd.objects.APartType;
|
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.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class KillListener implements Listener {
|
public class KillListener implements Listener {
|
||||||
private final List<APartType> particlesToActivate;
|
private final List<APartType> particlesToActivate;
|
||||||
@@ -29,20 +23,6 @@ public class KillListener implements Listener {
|
|||||||
Player player = event.getEntity().getKiller();
|
Player player = event.getEntity().getKiller();
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
new BukkitRunnable() {
|
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, player, () -> event.getEntity().getLocation());
|
||||||
@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 {
|
public class PlayerQuitListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerLeave(PlayerQuitEvent event) {
|
public void onPlayerLeave(PlayerQuitEvent event) { //TODO particles when a player leaves
|
||||||
PlayerSettings.removePlayer(event.getPlayer().getUniqueId());
|
PlayerSettings.removePlayer(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package com.alttd.listeners;
|
package com.alttd.listeners;
|
||||||
|
|
||||||
import com.alttd.AltitudeParticles;
|
|
||||||
import com.alttd.objects.APartType;
|
import com.alttd.objects.APartType;
|
||||||
import com.alttd.objects.ParticleSet;
|
|
||||||
import com.alttd.storage.PlayerSettings;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -14,10 +11,8 @@ import org.bukkit.event.block.Action;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class RightClickListener implements Listener {
|
public class RightClickListener implements Listener {
|
||||||
|
|
||||||
@@ -38,22 +33,7 @@ public class RightClickListener implements Listener {
|
|||||||
Block clickedBlock = event.getClickedBlock();
|
Block clickedBlock = event.getClickedBlock();
|
||||||
if (clickedBlock == null)
|
if (clickedBlock == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UUID uuid = player.getUniqueId();
|
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, player, player::getLocation);
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
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,19 +1,12 @@
|
|||||||
package com.alttd.listeners;
|
package com.alttd.listeners;
|
||||||
|
|
||||||
import com.alttd.AltitudeParticles;
|
|
||||||
import com.alttd.objects.APartType;
|
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.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class TeleportArriveListener implements Listener {
|
public class TeleportArriveListener implements Listener {
|
||||||
private final List<APartType> particlesToActivate;
|
private final List<APartType> particlesToActivate;
|
||||||
@@ -26,22 +19,7 @@ public class TeleportArriveListener implements Listener {
|
|||||||
public void onTeleportArrive(PlayerTeleportEvent event) {
|
public void onTeleportArrive(PlayerTeleportEvent event) {
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
new BukkitRunnable() {
|
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, event.getPlayer(), event::getTo);
|
||||||
@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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.alttd.objects;
|
package com.alttd.objects;
|
||||||
|
|
||||||
import com.alttd.config.Config;
|
import com.alttd.config.Config;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@@ -15,37 +17,19 @@ public enum APartType { //TODO add description?
|
|||||||
CLICK_BLOCK("CLICK_BLOCK", "Right click block", Material.DIAMOND_BLOCK, TimeUnit.SECONDS.toMillis(Config.CLICK_BLOCK_COOL_DOWN), null, true),
|
CLICK_BLOCK("CLICK_BLOCK", "Right click block", Material.DIAMOND_BLOCK, TimeUnit.SECONDS.toMillis(Config.CLICK_BLOCK_COOL_DOWN), null, true),
|
||||||
TELEPORT_ARRIVE("TELEPORT", "Teleport", Material.DRAGON_EGG, TimeUnit.SECONDS.toMillis(Config.TELEPORT_ARRIVE_COOL_DOWN), null, true);
|
TELEPORT_ARRIVE("TELEPORT", "Teleport", Material.DRAGON_EGG, TimeUnit.SECONDS.toMillis(Config.TELEPORT_ARRIVE_COOL_DOWN), null, true);
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@Getter
|
||||||
private final String displayName;
|
private final String displayName;
|
||||||
|
@Getter
|
||||||
private final Material material;
|
private final Material material;
|
||||||
|
@Getter
|
||||||
private final long delay;
|
private final long delay;
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private ItemStack itemStack;
|
private ItemStack itemStack;
|
||||||
private final boolean event;
|
private final boolean event;
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplayName() {
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial() {
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getDelay() {
|
|
||||||
return delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getItemStack() {
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemStack(ItemStack itemStack) {
|
|
||||||
this.itemStack = itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasEvent() {
|
public boolean hasEvent() {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.alttd.objects;
|
package com.alttd.objects;
|
||||||
|
|
||||||
import com.alttd.config.Config;
|
|
||||||
import com.alttd.storage.PlayerSettings;
|
import com.alttd.storage.PlayerSettings;
|
||||||
import com.alttd.util.Logger;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
@@ -24,18 +22,18 @@ public class Frame {
|
|||||||
*/
|
*/
|
||||||
public void spawn(Location location, float rotation) {
|
public void spawn(Location location, float rotation) {
|
||||||
Location tmpLocation = location.clone();
|
Location tmpLocation = location.clone();
|
||||||
AParticles.forEach(AParticle -> {
|
AParticles.forEach(aParticle -> {
|
||||||
ThreadLocalRandom current = ThreadLocalRandom.current();
|
ThreadLocalRandom current = ThreadLocalRandom.current();
|
||||||
double offsetX = ((AParticle.offset_range() == 0) ? 0 : current.nextDouble(-AParticle.offset_range(), AParticle.offset_range()));
|
double offsetX = ((aParticle.offset_range() == 0) ? 0 : current.nextDouble(-aParticle.offset_range(), aParticle.offset_range()));
|
||||||
double offsetZ = ((AParticle.offset_range() == 0) ? 0 : current.nextDouble(-AParticle.offset_range(), AParticle.offset_range()));
|
double offsetZ = ((aParticle.offset_range() == 0) ? 0 : current.nextDouble(-aParticle.offset_range(), aParticle.offset_range()));
|
||||||
double offsetY = ((AParticle.offset_range() == 0) ? 0 : current.nextDouble(-AParticle.offset_range(), AParticle.offset_range()));
|
double offsetY = ((aParticle.offset_range() == 0) ? 0 : current.nextDouble(-aParticle.offset_range(), aParticle.offset_range()));
|
||||||
XZ xz = new XZ(location.getX(), location.getX() + AParticle.x() + offsetX,
|
XZ xz = new XZ(location.getX(), location.getX() + aParticle.x() + offsetX,
|
||||||
location.getZ(), location.getZ() + AParticle.z() + offsetZ,
|
location.getZ(), location.getZ() + aParticle.z() + offsetZ,
|
||||||
rotation);
|
rotation);
|
||||||
AParticle.particleBuilder()
|
aParticle.particleBuilder()
|
||||||
.location(tmpLocation.set(
|
.location(tmpLocation.set(
|
||||||
xz.getRotatedX(),
|
xz.getRotatedX(),
|
||||||
location.getY() + AParticle.y() + offsetY,
|
location.getY() + aParticle.y() + offsetY,
|
||||||
xz.getRotatedZ()))
|
xz.getRotatedZ()))
|
||||||
.receivers(Bukkit.getOnlinePlayers().stream()
|
.receivers(Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(player -> {
|
.filter(player -> {
|
||||||
@@ -51,7 +49,7 @@ public class Frame {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class XZ {
|
private static class XZ {
|
||||||
private final double cx, cz; //Coordinates to rotate around
|
private final double cx, cz; //Coordinates to rotate around
|
||||||
private double x, z; //Coordinated to rotate
|
private double x, z; //Coordinated to rotate
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.alttd.frameSpawners.FrameSpawnerPlayer;
|
|||||||
import com.alttd.storage.PlayerSettings;
|
import com.alttd.storage.PlayerSettings;
|
||||||
import com.alttd.util.Logger;
|
import com.alttd.util.Logger;
|
||||||
import de.myzelyam.api.vanish.VanishAPI;
|
import de.myzelyam.api.vanish.VanishAPI;
|
||||||
|
import lombok.Getter;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -22,10 +23,14 @@ public class ParticleSet {
|
|||||||
|
|
||||||
private final List<Frame> frames;
|
private final List<Frame> frames;
|
||||||
private final int frameDelay, repeat, repeatDelay;
|
private final int frameDelay, repeat, repeatDelay;
|
||||||
|
@Getter
|
||||||
private final APartType aPartType;
|
private final APartType aPartType;
|
||||||
private final String uniqueId;
|
private final String uniqueId;
|
||||||
|
@Getter
|
||||||
private final String permission;
|
private final String permission;
|
||||||
|
@Getter
|
||||||
private final String packPermission;
|
private final String packPermission;
|
||||||
|
@Getter
|
||||||
private final ItemStack itemStack;
|
private final ItemStack itemStack;
|
||||||
private final boolean stationary;
|
private final boolean stationary;
|
||||||
|
|
||||||
@@ -77,22 +82,6 @@ public class ParticleSet {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public APartType getAPartType() {
|
|
||||||
return aPartType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPermission() {
|
|
||||||
return permission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPackPermission() {
|
|
||||||
return packPermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getItemStack() {
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParticleId() {
|
public String getParticleId() {
|
||||||
return uniqueId;
|
return uniqueId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.alttd.storage;
|
|||||||
import com.alttd.database.Queries;
|
import com.alttd.database.Queries;
|
||||||
import com.alttd.objects.APartType;
|
import com.alttd.objects.APartType;
|
||||||
import com.alttd.objects.ParticleSet;
|
import com.alttd.objects.ParticleSet;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -12,8 +13,12 @@ public class PlayerSettings {
|
|||||||
|
|
||||||
private static final HashMap<UUID, PlayerSettings> playerSettingsMap = new HashMap<>();
|
private static final HashMap<UUID, PlayerSettings> playerSettingsMap = new HashMap<>();
|
||||||
|
|
||||||
private boolean particlesActive, seeingParticles;
|
private boolean particlesActive;
|
||||||
|
@Getter
|
||||||
|
private boolean seeingParticles;
|
||||||
|
@Getter
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
@Getter
|
||||||
private final HashMap<APartType, ParticleSet> particles;
|
private final HashMap<APartType, ParticleSet> particles;
|
||||||
private final HashMap<APartType, Long> lastUsed;
|
private final HashMap<APartType, Long> lastUsed;
|
||||||
|
|
||||||
@@ -54,23 +59,11 @@ public class PlayerSettings {
|
|||||||
return particlesActive;
|
return particlesActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSeeingParticles() {
|
|
||||||
return seeingParticles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean toggleSeeingParticles() {
|
public boolean toggleSeeingParticles() {
|
||||||
seeingParticles = !seeingParticles;
|
seeingParticles = !seeingParticles;
|
||||||
return seeingParticles;
|
return seeingParticles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUuid() {
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<APartType, ParticleSet> getParticles() {
|
|
||||||
return particles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addParticle(APartType aPartType, ParticleSet particleSet) {
|
public void addParticle(APartType aPartType, ParticleSet particleSet) {
|
||||||
particles.put(aPartType, particleSet);
|
particles.put(aPartType, particleSet);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.alttd.util;
|
|||||||
|
|
||||||
import com.alttd.AltitudeParticles;
|
import com.alttd.AltitudeParticles;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Logger {
|
public class Logger {
|
||||||
|
|
||||||
static private final java.util.logging.Logger logger;
|
static private final java.util.logging.Logger logger;
|
||||||
@@ -33,4 +35,8 @@ public class Logger {
|
|||||||
}
|
}
|
||||||
logger.severe(severe);
|
logger.severe(severe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void error(String error, Throwable throwable) {
|
||||||
|
logger.log(Level.SEVERE, error, throwable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user