mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-02-21 15:34:34 +00:00
Add style 'rings', code cleanup
This commit is contained in:
parent
36803440c0
commit
200103a5c9
16 changed files with 196 additions and 80 deletions
|
@ -3,7 +3,6 @@
|
||||||
* + Add new style 'tornado'
|
* + Add new style 'tornado'
|
||||||
* + Add new style 'companion'
|
* + Add new style 'companion'
|
||||||
* + Add new style 'atom'
|
* + Add new style 'atom'
|
||||||
* + Add new style 'rings'
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.esophose.playerparticles;
|
package com.esophose.playerparticles;
|
||||||
|
@ -42,7 +41,7 @@ public class PlayerParticles extends JavaPlugin {
|
||||||
/**
|
/**
|
||||||
* The database connection manager
|
* The database connection manager
|
||||||
*/
|
*/
|
||||||
public static DatabaseConnector databaseConnector = null;
|
private static DatabaseConnector databaseConnector = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers all the styles available by default
|
* Registers all the styles available by default
|
||||||
|
@ -81,6 +80,7 @@ public class PlayerParticles extends JavaPlugin {
|
||||||
LangManager.setup();
|
LangManager.setup();
|
||||||
|
|
||||||
configureDatabase(getConfig().getBoolean("database-enable"));
|
configureDatabase(getConfig().getBoolean("database-enable"));
|
||||||
|
ParticleManager.refreshData();
|
||||||
startParticleTask();
|
startParticleTask();
|
||||||
|
|
||||||
if (shouldCheckUpdates()) {
|
if (shouldCheckUpdates()) {
|
||||||
|
@ -117,6 +117,15 @@ public class PlayerParticles extends JavaPlugin {
|
||||||
public static Plugin getPlugin() {
|
public static Plugin getPlugin() {
|
||||||
return pluginInstance;
|
return pluginInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the DatabaseConnector that allows querying the database
|
||||||
|
*
|
||||||
|
* @return The DatabaseConnector
|
||||||
|
*/
|
||||||
|
public static DatabaseConnector getDBConnector() {
|
||||||
|
return databaseConnector;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the config if the plugin can look for updates
|
* Checks the config if the plugin can look for updates
|
||||||
|
@ -214,7 +223,6 @@ public class PlayerParticles extends JavaPlugin {
|
||||||
final Plugin playerParticles = this;
|
final Plugin playerParticles = this;
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
ParticleManager.refreshPPlayers(); // Add any online players who have particles
|
|
||||||
PlayerParticlesGui.setup();
|
PlayerParticlesGui.setup();
|
||||||
|
|
||||||
long ticks = getConfig().getLong("ticks-per-particle");
|
long ticks = getConfig().getLong("ticks-per-particle");
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.bukkit.util.StringUtil;
|
||||||
import com.esophose.playerparticles.manager.DataManager;
|
import com.esophose.playerparticles.manager.DataManager;
|
||||||
import com.esophose.playerparticles.manager.LangManager;
|
import com.esophose.playerparticles.manager.LangManager;
|
||||||
import com.esophose.playerparticles.manager.LangManager.Lang;
|
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||||
import com.esophose.playerparticles.manager.ParticleManager;
|
|
||||||
import com.esophose.playerparticles.manager.PermissionManager;
|
import com.esophose.playerparticles.manager.PermissionManager;
|
||||||
import com.esophose.playerparticles.particles.PPlayer;
|
import com.esophose.playerparticles.particles.PPlayer;
|
||||||
import com.esophose.playerparticles.particles.ParticleEffect;
|
import com.esophose.playerparticles.particles.ParticleEffect;
|
||||||
|
@ -31,7 +30,7 @@ public class AddCommandModule implements CommandModule {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleEffect effect = ParticleManager.effectFromString(args[0]);
|
ParticleEffect effect = ParticleEffect.fromName(args[0]);
|
||||||
if (effect == null) {
|
if (effect == null) {
|
||||||
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
|
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class FixedCommandModule implements CommandModule {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleEffect effect = ParticleManager.effectFromString(args[3]);
|
ParticleEffect effect = ParticleEffect.fromName(args[3]);
|
||||||
if (effect == null) {
|
if (effect == null) {
|
||||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_EFFECT_INVALID, args[3]);
|
LangManager.sendMessage(p, Lang.FIXED_CREATE_EFFECT_INVALID, args[3]);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -519,7 +519,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
||||||
List<String> effectsUserHasPermissionFor = PermissionManager.getEffectsUserHasPermissionFor(player);
|
List<String> effectsUserHasPermissionFor = PermissionManager.getEffectsUserHasPermissionFor(player);
|
||||||
for (int i = 0; i < effectsUserHasPermissionFor.size(); i++) {
|
for (int i = 0; i < effectsUserHasPermissionFor.size(); i++) {
|
||||||
String s = effectsUserHasPermissionFor.get(i);
|
String s = effectsUserHasPermissionFor.get(i);
|
||||||
ParticleEffect effect = ParticleManager.effectFromString(s);
|
ParticleEffect effect = ParticleEffect.fromName(s);
|
||||||
inventory.setItem(i, getItemForEffect(effect, effect == getPPlayerEffect(pplayer)));
|
inventory.setItem(i, getItemForEffect(effect, effect == getPPlayerEffect(pplayer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +706,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EFFECT:
|
case EFFECT:
|
||||||
setPPlayerEffect(pplayer, ParticleManager.effectFromString(name));
|
setPPlayerEffect(pplayer, ParticleEffect.fromName(name));
|
||||||
changeState(pplayer, GuiState.DEFAULT);
|
changeState(pplayer, GuiState.DEFAULT);
|
||||||
break;
|
break;
|
||||||
case STYLE:
|
case STYLE:
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class DataManager {
|
||||||
List<ParticleGroup> groups = new ArrayList<ParticleGroup>();
|
List<ParticleGroup> groups = new ArrayList<ParticleGroup>();
|
||||||
List<FixedParticleEffect> fixedParticles = new ArrayList<FixedParticleEffect>();
|
List<FixedParticleEffect> fixedParticles = new ArrayList<FixedParticleEffect>();
|
||||||
|
|
||||||
PlayerParticles.databaseConnector.connect((connection) -> {
|
PlayerParticles.getDBConnector().connect((connection) -> {
|
||||||
// Load particle groups
|
// Load particle groups
|
||||||
String groupQuery = "SELECT * FROM pp_group g " + // @formatter:off
|
String groupQuery = "SELECT * FROM pp_group g " + // @formatter:off
|
||||||
"JOIN pp_particle p ON g.uuid = p.group_uuid " +
|
"JOIN pp_particle p ON g.uuid = p.group_uuid " +
|
||||||
|
@ -167,6 +167,24 @@ public class DataManager {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all PPlayers from the database that own FixedParticleEffects
|
||||||
|
*/
|
||||||
|
public static void loadFixedEffects() {
|
||||||
|
async(() -> {
|
||||||
|
PlayerParticles.getDBConnector().connect((connection) -> {
|
||||||
|
String query = "SELECT DISTINCT owner_uuid FROM pp_fixed";
|
||||||
|
try (PreparedStatement statement = connection.prepareStatement(query)) {
|
||||||
|
ResultSet result = statement.executeQuery();
|
||||||
|
while (result.next()) {
|
||||||
|
UUID playerUUID = UUID.fromString(result.getString("owner_uuid"));
|
||||||
|
getPPlayer(playerUUID, (pplayer) -> { });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a ParticleGroup. If it already exists, update it.
|
* Saves a ParticleGroup. If it already exists, update it.
|
||||||
|
@ -176,7 +194,7 @@ public class DataManager {
|
||||||
*/
|
*/
|
||||||
public static void saveParticleGroup(UUID playerUUID, ParticleGroup group) {
|
public static void saveParticleGroup(UUID playerUUID, ParticleGroup group) {
|
||||||
async(() -> {
|
async(() -> {
|
||||||
PlayerParticles.databaseConnector.connect((connection) -> {
|
PlayerParticles.getDBConnector().connect((connection) -> {
|
||||||
String groupUUIDQuery = "SELECT uuid FROM pp_group WHERE owner_uuid = ? AND name = ?";
|
String groupUUIDQuery = "SELECT uuid FROM pp_group WHERE owner_uuid = ? AND name = ?";
|
||||||
try (PreparedStatement statement = connection.prepareStatement(groupUUIDQuery)) {
|
try (PreparedStatement statement = connection.prepareStatement(groupUUIDQuery)) {
|
||||||
statement.setString(1, playerUUID.toString());
|
statement.setString(1, playerUUID.toString());
|
||||||
|
@ -247,7 +265,7 @@ public class DataManager {
|
||||||
*/
|
*/
|
||||||
public static void removeParticleGroup(UUID playerUUID, ParticleGroup group) {
|
public static void removeParticleGroup(UUID playerUUID, ParticleGroup group) {
|
||||||
async(() -> {
|
async(() -> {
|
||||||
PlayerParticles.databaseConnector.connect((connection) -> {
|
PlayerParticles.getDBConnector().connect((connection) -> {
|
||||||
String groupQuery = "SELECT * FROM pp_group WHERE owner_uuid = ? AND name = ?";
|
String groupQuery = "SELECT * FROM pp_group WHERE owner_uuid = ? AND name = ?";
|
||||||
String particleDeleteQuery = "DELETE FROM pp_particle WHERE group_uuid = ?";
|
String particleDeleteQuery = "DELETE FROM pp_particle WHERE group_uuid = ?";
|
||||||
String groupDeleteQuery = "DELETE FROM pp_group WHERE uuid = ?";
|
String groupDeleteQuery = "DELETE FROM pp_group WHERE uuid = ?";
|
||||||
|
@ -291,7 +309,7 @@ public class DataManager {
|
||||||
*/
|
*/
|
||||||
public static void saveFixedEffect(FixedParticleEffect fixedEffect) {
|
public static void saveFixedEffect(FixedParticleEffect fixedEffect) {
|
||||||
async(() -> {
|
async(() -> {
|
||||||
PlayerParticles.databaseConnector.connect((connection) -> {
|
PlayerParticles.getDBConnector().connect((connection) -> {
|
||||||
String particleUUID = UUID.randomUUID().toString();
|
String particleUUID = UUID.randomUUID().toString();
|
||||||
|
|
||||||
String particleQuery = "INSERT INTO pp_particle (uuid, group_uuid, id, effect, style, item_material, block_material, note, r, g, b) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
String particleQuery = "INSERT INTO pp_particle (uuid, group_uuid, id, effect, style, item_material, block_material, note, r, g, b) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
@ -339,7 +357,7 @@ public class DataManager {
|
||||||
*/
|
*/
|
||||||
public static void removeFixedEffect(UUID playerUUID, int id) {
|
public static void removeFixedEffect(UUID playerUUID, int id) {
|
||||||
async(() -> {
|
async(() -> {
|
||||||
PlayerParticles.databaseConnector.connect((connection) -> {
|
PlayerParticles.getDBConnector().connect((connection) -> {
|
||||||
String particleUUID = null;
|
String particleUUID = null;
|
||||||
|
|
||||||
String particleUUIDQuery = "SELECT particle_uuid FROM pp_fixed WHERE owner_uuid = ? AND id = ?";
|
String particleUUIDQuery = "SELECT particle_uuid FROM pp_fixed WHERE owner_uuid = ? AND id = ?";
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
DataManager.getPPlayer(e.getPlayer().getUniqueId(), (pplayer) -> {
|
DataManager.getPPlayer(e.getPlayer().getUniqueId(), (pplayer) -> {
|
||||||
|
System.out.println("Loaded");
|
||||||
}); // Loads the PPlayer from the database
|
}); // Loads the PPlayer from the database
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||||
PPlayer pplayer = DataManager.getPPlayer(e.getPlayer().getUniqueId());
|
PPlayer pplayer = DataManager.getPPlayer(e.getPlayer().getUniqueId());
|
||||||
if (pplayer != null) particlePlayers.remove(pplayer);
|
if (pplayer != null && pplayer.getFixedEffectIds().isEmpty()) particlePlayers.remove(pplayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,43 +72,17 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a PPlayer for all players on the server who have active particles or fixed effects
|
* Loads all FixedParticleEffects from the database
|
||||||
|
* Loads all online PPlayers from the database
|
||||||
*/
|
*/
|
||||||
public static void refreshPPlayers() {
|
public static void refreshData() {
|
||||||
particlePlayers.clear();
|
particlePlayers.clear();
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
DataManager.loadFixedEffects();
|
||||||
DataManager.getPPlayer(player.getUniqueId(), (pplayer) -> {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
}); // Loads the PPlayer from the database
|
DataManager.getPPlayer(player.getUniqueId(), (pplayer) -> { }); // Loads the PPlayer from the database
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overrides an existing PPlayer with the same UUID
|
|
||||||
*
|
|
||||||
* @param pplayer The PPlayer to override
|
|
||||||
*/
|
|
||||||
public static void updateIfContains(PPlayer pplayer) {
|
|
||||||
for (PPlayer pp : particlePlayers) {
|
|
||||||
if (pp.getUniqueId() == pplayer.getUniqueId()) {
|
|
||||||
particlePlayers.remove(pp);
|
|
||||||
particlePlayers.add(pplayer);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets an effect type from a string, used for getting ParticleEffects from the saved data
|
|
||||||
*
|
|
||||||
* @param effectName The name of the particle to check for
|
|
||||||
* @return The ParticleEffect with the given name, will be null if name was not found
|
|
||||||
*/
|
|
||||||
public static ParticleEffect effectFromString(String effectName) {
|
|
||||||
for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) {
|
|
||||||
if (effect.getName().equalsIgnoreCase(effectName)) return effect;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main loop to display all the particles
|
* The main loop to display all the particles
|
||||||
* Does not display particles if the world is disabled or if the player is in spectator mode
|
* Does not display particles if the world is disabled or if the player is in spectator mode
|
||||||
|
|
|
@ -206,7 +206,6 @@ public enum ParticleEffect {
|
||||||
for (Player player : getPlayersInRange(center)) {
|
for (Player player : getPlayersInRange(center)) {
|
||||||
player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed);
|
player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,7 +271,6 @@ public enum ParticleEffect {
|
||||||
} else if (internalEnum.getDataType() == MaterialData.class) {
|
} else if (internalEnum.getDataType() == MaterialData.class) {
|
||||||
extraData = new MaterialData(spawnMaterial); // Deprecated, only used in versions < 1.13
|
extraData = new MaterialData(spawnMaterial); // Deprecated, only used in versions < 1.13
|
||||||
} else {
|
} else {
|
||||||
System.out.println(internalEnum.getDataType());
|
|
||||||
extraData = null;
|
extraData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class DefaultStyles {
|
||||||
public static final ParticleStyle ORBIT = new ParticleStyleOrbit();
|
public static final ParticleStyle ORBIT = new ParticleStyleOrbit();
|
||||||
public static final ParticleStyle POINT = new ParticleStylePoint();
|
public static final ParticleStyle POINT = new ParticleStylePoint();
|
||||||
public static final ParticleStyle QUADHELIX = new ParticleStyleQuadhelix();
|
public static final ParticleStyle QUADHELIX = new ParticleStyleQuadhelix();
|
||||||
|
public static final ParticleStyle RINGS = new ParticleStyleRings();
|
||||||
public static final ParticleStyle SPHERE = new ParticleStyleSphere();
|
public static final ParticleStyle SPHERE = new ParticleStyleSphere();
|
||||||
public static final ParticleStyle SPIN = new ParticleStyleSpin();
|
public static final ParticleStyle SPIN = new ParticleStyleSpin();
|
||||||
public static final ParticleStyle SPIRAL = new ParticleStyleSpiral();
|
public static final ParticleStyle SPIRAL = new ParticleStyleSpiral();
|
||||||
|
@ -54,6 +55,7 @@ public class DefaultStyles {
|
||||||
ParticleStyleManager.registerStyle(ORBIT);
|
ParticleStyleManager.registerStyle(ORBIT);
|
||||||
ParticleStyleManager.registerStyle(POINT);
|
ParticleStyleManager.registerStyle(POINT);
|
||||||
ParticleStyleManager.registerStyle(QUADHELIX);
|
ParticleStyleManager.registerStyle(QUADHELIX);
|
||||||
|
ParticleStyleManager.registerStyle(RINGS);
|
||||||
ParticleStyleManager.registerStyle(SPHERE);
|
ParticleStyleManager.registerStyle(SPHERE);
|
||||||
ParticleStyleManager.registerStyle(SPIN);
|
ParticleStyleManager.registerStyle(SPIN);
|
||||||
ParticleStyleManager.registerStyle(SPIRAL);
|
ParticleStyleManager.registerStyle(SPIRAL);
|
||||||
|
|
|
@ -11,19 +11,30 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
|
||||||
|
|
||||||
public class ParticleStyleBeam implements ParticleStyle {
|
public class ParticleStyleBeam implements ParticleStyle {
|
||||||
|
|
||||||
|
private static double[] cos, sin;
|
||||||
|
private static final int points = 16;
|
||||||
private int step = 0;
|
private int step = 0;
|
||||||
private boolean reversed = false;
|
private boolean reversed = false;
|
||||||
|
|
||||||
|
static {
|
||||||
|
cos = new double[points];
|
||||||
|
sin = new double[points];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (double n = 0; n < Math.PI * 2; n += Math.PI * 2 / points) {
|
||||||
|
cos[i] = Math.cos(n);
|
||||||
|
sin[i] = Math.sin(n);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
||||||
int points = 16;
|
|
||||||
double radius = 1;
|
double radius = 1;
|
||||||
double slice = 2 * Math.PI / points;
|
|
||||||
List<PParticle> particles = new ArrayList<PParticle>();
|
List<PParticle> particles = new ArrayList<PParticle>();
|
||||||
for (int i = 0; i < points; i++) {
|
for (int i = 0; i < points; i++) {
|
||||||
double angle = slice * i;
|
double newX = location.getX() + radius * cos[i];
|
||||||
double newX = location.getX() + radius * Math.cos(angle);
|
|
||||||
double newY = location.getY() + (step / 10D) - 1;
|
double newY = location.getY() + (step / 10D) - 1;
|
||||||
double newZ = location.getZ() + radius * Math.sin(angle);
|
double newZ = location.getZ() + radius * sin[i];
|
||||||
particles.add(new PParticle(new Location(location.getWorld(), newX, newY, newZ)));
|
particles.add(new PParticle(new Location(location.getWorld(), newX, newY, newZ)));
|
||||||
}
|
}
|
||||||
return particles;
|
return particles;
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class ParticleStyleCube implements ParticleStyle {
|
||||||
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
||||||
List<PParticle> pparticles = new ArrayList<PParticle>();
|
List<PParticle> pparticles = new ArrayList<PParticle>();
|
||||||
|
|
||||||
if (!skipNextStep) {
|
if (!skipNextStep) { // TODO: relative position lookup tables
|
||||||
double xRotation = 0, yRotation = 0, zRotation = 0;
|
double xRotation = 0, yRotation = 0, zRotation = 0;
|
||||||
xRotation = step * angularVelocityX;
|
xRotation = step * angularVelocityX;
|
||||||
yRotation = step * angularVelocityY;
|
yRotation = step * angularVelocityY;
|
||||||
|
|
|
@ -11,21 +11,33 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
|
||||||
|
|
||||||
public class ParticleStyleHalo implements ParticleStyle {
|
public class ParticleStyleHalo implements ParticleStyle {
|
||||||
|
|
||||||
|
private static double[] cos, sin;
|
||||||
|
private static final int points = 16;
|
||||||
private int step = 0;
|
private int step = 0;
|
||||||
|
|
||||||
|
static {
|
||||||
|
cos = new double[points];
|
||||||
|
sin = new double[points];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (double n = 0; n < Math.PI * 2; n += Math.PI * 2 / points) {
|
||||||
|
cos[i] = Math.cos(n);
|
||||||
|
sin[i] = Math.sin(n);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
||||||
if (step % 2 == 0) return new ArrayList<PParticle>();
|
if (step % 2 == 0) return new ArrayList<PParticle>();
|
||||||
|
|
||||||
int points = 16;
|
int points = 16;
|
||||||
double radius = .65;
|
double radius = .65;
|
||||||
double slice = 2 * Math.PI / points;
|
|
||||||
List<PParticle> particles = new ArrayList<PParticle>();
|
List<PParticle> particles = new ArrayList<PParticle>();
|
||||||
for (int i = 0; i < points; i++) {
|
for (int i = 0; i < points; i++) {
|
||||||
double angle = slice * i;
|
double dx = location.getX() + radius * cos[i];
|
||||||
double newX = location.getX() + radius * Math.cos(angle);
|
double dy = location.getY() + 1.5;
|
||||||
double newY = location.getY() + 1.5;
|
double dz = location.getZ() + radius * sin[i];
|
||||||
double newZ = location.getZ() + radius * Math.sin(angle);
|
particles.add(new PParticle(location.clone().add(dx, dy, dz)));
|
||||||
particles.add(new PParticle(new Location(location.getWorld(), newX, newY, newZ)));
|
|
||||||
}
|
}
|
||||||
return particles;
|
return particles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,22 +11,36 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
|
||||||
|
|
||||||
public class ParticleStyleOrbit implements ParticleStyle {
|
public class ParticleStyleOrbit implements ParticleStyle {
|
||||||
|
|
||||||
|
private static double[] cos, sin;
|
||||||
|
private static final int orbs = 3;
|
||||||
|
private static final int numSteps = 120;
|
||||||
private int step = 0;
|
private int step = 0;
|
||||||
|
|
||||||
|
static {
|
||||||
|
cos = new double[120];
|
||||||
|
sin = new double[120];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (double n = 0; n < numSteps; n++) {
|
||||||
|
cos[i] = -Math.cos(n / numSteps * Math.PI * 2);
|
||||||
|
sin[i] = -Math.sin(n / numSteps * Math.PI * 2);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
||||||
int orbs = 3;
|
|
||||||
List<PParticle> particles = new ArrayList<PParticle>();
|
List<PParticle> particles = new ArrayList<PParticle>();
|
||||||
for (int i = 0; i < orbs; i++) {
|
for (int i = 0; i < orbs; i++) {
|
||||||
double dx = -(Math.cos((step / 120D) * (Math.PI * 2) + (((Math.PI * 2) / orbs) * i)));
|
double dx = cos[(step + (numSteps / orbs * i)) % numSteps];
|
||||||
double dz = -(Math.sin((step / 120D) * (Math.PI * 2) + (((Math.PI * 2) / orbs) * i)));
|
double dz = sin[(step + (numSteps / orbs * i)) % numSteps];
|
||||||
particles.add(new PParticle(new Location(location.getWorld(), location.getX() + dx, location.getY(), location.getZ() + dz)));
|
particles.add(new PParticle(location.clone().add(dx, 0, dz)));
|
||||||
}
|
}
|
||||||
return particles;
|
return particles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTimers() {
|
public void updateTimers() {
|
||||||
step++;
|
step++;
|
||||||
if (step > 120) {
|
if (step > numSteps) {
|
||||||
step = 0;
|
step = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,33 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
|
||||||
|
|
||||||
public class ParticleStyleQuadhelix implements ParticleStyle {
|
public class ParticleStyleQuadhelix implements ParticleStyle {
|
||||||
|
|
||||||
|
private static double[] cos, sin;
|
||||||
|
private static final int orbs = 4;
|
||||||
|
private static int maxStepX = 80;
|
||||||
|
private static int maxStepY = 60;
|
||||||
private int stepX = 0;
|
private int stepX = 0;
|
||||||
private int maxStepX = 90;
|
|
||||||
private int stepY = 0;
|
private int stepY = 0;
|
||||||
private int maxStepY = 60;
|
|
||||||
private boolean reverse = false;
|
private boolean reverse = false;
|
||||||
|
|
||||||
|
static {
|
||||||
|
cos = new double[maxStepX];
|
||||||
|
sin = new double[maxStepX];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (double n = 0; n < maxStepX; n++) {
|
||||||
|
cos[i] = -Math.cos(n / maxStepX * Math.PI * 2);
|
||||||
|
sin[i] = -Math.sin(n / maxStepX * Math.PI * 2);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
||||||
List<PParticle> particles = new ArrayList<PParticle>();
|
List<PParticle> particles = new ArrayList<PParticle>();
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < orbs; i++) {
|
||||||
double dx = -(Math.cos((stepX / (double)maxStepX) * (Math.PI * 2) + ((Math.PI / 2) * i))) * ((60 - Math.abs(stepY)) / (double)maxStepY);
|
int step = (stepX + (maxStepX / orbs) * i) % maxStepX;
|
||||||
|
double dx = cos[step] * ((60 - Math.abs(stepY)) / (double)maxStepY);
|
||||||
double dy = (stepY / (double)maxStepY) * 1.5;
|
double dy = (stepY / (double)maxStepY) * 1.5;
|
||||||
double dz = -(Math.sin((stepX / (double)maxStepX) * (Math.PI * 2) + ((Math.PI / 2) * i))) * ((60 - Math.abs(stepY)) / (double)maxStepY);
|
double dz = sin[step] * ((60 - Math.abs(stepY)) / (double)maxStepY);
|
||||||
particles.add(new PParticle(location.clone().add(dx, dy, dz)));
|
particles.add(new PParticle(location.clone().add(dx, dy, dz)));
|
||||||
}
|
}
|
||||||
return particles;
|
return particles;
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.esophose.playerparticles.styles;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import com.esophose.playerparticles.particles.ParticlePair;
|
||||||
|
import com.esophose.playerparticles.styles.api.PParticle;
|
||||||
|
import com.esophose.playerparticles.styles.api.ParticleStyle;
|
||||||
|
|
||||||
|
public class ParticleStyleRings implements ParticleStyle {
|
||||||
|
|
||||||
|
private static double[] cos, sin;
|
||||||
|
private int index = 0;
|
||||||
|
|
||||||
|
static {
|
||||||
|
cos = new double[32];
|
||||||
|
sin = new double[32];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (double n = 0; n < Math.PI * 2; n += Math.PI / 16) {
|
||||||
|
cos[i] = Math.sin(n);
|
||||||
|
sin[i] = Math.cos(n);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
||||||
|
List<PParticle> particles = new ArrayList<PParticle>();
|
||||||
|
|
||||||
|
particles.add(new PParticle(location.clone().add(cos[index], sin[index], sin[index])));
|
||||||
|
particles.add(new PParticle(location.clone().add(cos[wrap(index + 16)], sin[wrap(index + 16)], sin[wrap(index + 16)])));
|
||||||
|
particles.add(new PParticle(location.clone().add(cos[wrap(index + 16)], sin[index], sin[wrap(index + 16)])));
|
||||||
|
particles.add(new PParticle(location.clone().add(cos[index], sin[wrap(index + 16)], sin[index])));
|
||||||
|
|
||||||
|
return particles;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int wrap(int index) {
|
||||||
|
return index % cos.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTimers() {
|
||||||
|
index = (index + 1) % cos.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "rings";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBeFixed() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,24 +11,32 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
|
||||||
|
|
||||||
public class ParticleStyleSpin implements ParticleStyle {
|
public class ParticleStyleSpin implements ParticleStyle {
|
||||||
|
|
||||||
|
private static double[] cos, sin;
|
||||||
|
private static final int maxSteps = 30;
|
||||||
private int step = 0;
|
private int step = 0;
|
||||||
|
|
||||||
|
static {
|
||||||
|
cos = new double[maxSteps];
|
||||||
|
sin = new double[maxSteps];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (double n = 0; n < Math.PI * 2; n += Math.PI * 2 / maxSteps) {
|
||||||
|
cos[i] = Math.cos(n);
|
||||||
|
sin[i] = Math.sin(n);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
||||||
int points = 15;
|
|
||||||
double radius = .5;
|
double radius = .5;
|
||||||
double slice = 2 * Math.PI / points;
|
double newX = location.getX() + radius * cos[step];
|
||||||
double angle = slice * (step % 15);
|
|
||||||
double newX = location.getX() + radius * Math.cos(angle);
|
|
||||||
double newY = location.getY() + 1.5;
|
double newY = location.getY() + 1.5;
|
||||||
double newZ = location.getZ() + radius * Math.sin(angle);
|
double newZ = location.getZ() + radius * sin[step];
|
||||||
return Collections.singletonList(new PParticle(new Location(location.getWorld(), newX, newY, newZ)));
|
return Collections.singletonList(new PParticle(new Location(location.getWorld(), newX, newY, newZ)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTimers() {
|
public void updateTimers() {
|
||||||
step++;
|
step = (step + 1) % maxSteps;
|
||||||
if (step > 30) {
|
|
||||||
step = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
@ -68,7 +68,7 @@ rainbow: '&cr&6a&ei&an&bb&9o&dw'
|
||||||
effect-no-permission: '&cYou do not have permission to use the effect &b{0} &c!'
|
effect-no-permission: '&cYou do not have permission to use the effect &b{0} &c!'
|
||||||
effect-invalid: '&cThe effect &b{0} &cdoes not exist! Use &b/pp effects &cfor a list of effects you can use.'
|
effect-invalid: '&cThe effect &b{0} &cdoes not exist! Use &b/pp effects &cfor a list of effects you can use.'
|
||||||
effect-list: '&eYou can use the following effects: &b{0}'
|
effect-list: '&eYou can use the following effects: &b{0}'
|
||||||
effect-list-empoty: '&cYou do not have permission to use any effects!'
|
effect-list-empty: '&cYou do not have permission to use any effects!'
|
||||||
|
|
||||||
# Styles
|
# Styles
|
||||||
style-no-permission: '&cYou do not have permission to use the style &b{0} &c!'
|
style-no-permission: '&cYou do not have permission to use the style &b{0} &c!'
|
||||||
|
|
Loading…
Reference in a new issue