Fix file size, fix onenable errors, fix database queries, all particle calculations now use doubles, steps are now done consistently with ints, still unstable with lots of unimplemented features/commands

This commit is contained in:
Esophose 2018-09-27 02:42:41 -06:00
parent 8354f40a04
commit a433189b45
16 changed files with 154 additions and 126 deletions

View file

@ -42,7 +42,6 @@
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
<include>org.xerial:sqlite-jdbc</include>
</includes>
</artifactSet>
<filters>
@ -70,7 +69,6 @@
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
<include>org.xerial:sqlite-jdbc</include>
</includes>
</artifactSet>
<filters>
@ -98,7 +96,6 @@
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
<include>org.xerial:sqlite-jdbc</include>
</includes>
</artifactSet>
<filters>
@ -126,7 +123,6 @@
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
<include>org.xerial:sqlite-jdbc</include>
</includes>
</artifactSet>
<filters>
@ -154,7 +150,6 @@
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
<include>org.xerial:sqlite-jdbc</include>
</includes>
</artifactSet>
<filters>

View file

@ -150,7 +150,7 @@ public class PlayerParticles extends JavaPlugin {
}
if (!databaseConnector.isInitialized()) {
getLogger().severe("Unable to connect to the MySql database! Is your login information correct? Falling back to file database.");
getLogger().severe("Unable to connect to the MySQL database! Is your login information correct? Falling back to SQLite database instead.");
configureDatabase(false);
return;
}
@ -159,35 +159,56 @@ public class PlayerParticles extends JavaPlugin {
// Check if pp_users exists, if it does, this is an old database schema that needs to be deleted
try { // @formatter:off
try (Statement statement = connection.createStatement()) {
ResultSet result = statement.executeQuery("SHOW TABLES LIKE 'pp_users'");
String pp_usersQuery;
if (useMySql) {
pp_usersQuery = "SHOW TABLES LIKE 'pp_users'";
} else {
pp_usersQuery = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'pp_users'";
}
ResultSet result = statement.executeQuery(pp_usersQuery);
if (result.next()) {
statement.close();
Statement dropStatement = connection.createStatement();
dropStatement.addBatch("DROP TABLE pp_users");
dropStatement.addBatch("DROP TABLE pp_fixed");
dropStatement.addBatch("DROP TABLE pp_data_item");
dropStatement.addBatch("DROP TABLE pp_data_block");
dropStatement.addBatch("DROP TABLE pp_data_color");
dropStatement.addBatch("DROP TABLE pp_data_note");
dropStatement.addBatch("DROP TABLE IF EXISTS pp_users");
dropStatement.addBatch("DROP TABLE IF EXISTS pp_fixed");
dropStatement.addBatch("DROP TABLE IF EXISTS pp_data_item");
dropStatement.addBatch("DROP TABLE IF EXISTS pp_data_block");
dropStatement.addBatch("DROP TABLE IF EXISTS pp_data_color");
dropStatement.addBatch("DROP TABLE IF EXISTS pp_data_note");
dropStatement.executeBatch();
getLogger().warning("Deleted old " + (useMySql ? "MySQL" : "SQLite") + " database schema, it was out of date.");
}
}
// Check if pp_group exists, if it doesn't, we need to create all the tables
try (Statement statement = connection.createStatement()) {
ResultSet result = statement.executeQuery("SHOW TABLES LIKE 'pp_group'");
String pp_groupQuery;
if (useMySql) {
pp_groupQuery = "SHOW TABLES LIKE 'pp_group'";
} else {
pp_groupQuery = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'pp_group'";
}
ResultSet result = statement.executeQuery(pp_groupQuery);
if (!result.next()) {
statement.close();
Statement createStatement = connection.createStatement();
createStatement.addBatch("CREATE TABLE pp_player (uuid VARCHAR(36))");
createStatement.addBatch("CREATE TABLE pp_group (uuid VARCHAR(36), owner_uuid VARCHAR(36), name VARCHAR(100))");
createStatement.addBatch("CREATE TABLE pp_fixed (owner_uuid VARCHAR(36), id SMALLINT, particle_uuid VARCHAR(36), world VARCHAR(100), xPos DOUBLE, yPos DOUBLE, zPos DOUBLE)");
createStatement.addBatch("CREATE TABLE pp_particle (uuid VARCHAR(36), group_uuid VARCHAR(36), id SMALLINT, effect VARCHAR(100), style VARCHAR(100), item_material VARCHAR(100), block_material VARCHAR(100), note SMALLINT, r SMALLINT, g SMALLINT, b SMALLINT)");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS pp_group (uuid VARCHAR(36), owner_uuid VARCHAR(36), name VARCHAR(100))");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS pp_fixed (owner_uuid VARCHAR(36), id SMALLINT, particle_uuid VARCHAR(36), world VARCHAR(100), xPos DOUBLE, yPos DOUBLE, zPos DOUBLE)");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS pp_particle (uuid VARCHAR(36), group_uuid VARCHAR(36), id SMALLINT, effect VARCHAR(100), style VARCHAR(100), item_material VARCHAR(100), block_material VARCHAR(100), note SMALLINT, r SMALLINT, g SMALLINT, b SMALLINT)");
createStatement.executeBatch();
getLogger().warning("Created new " + (useMySql ? "MySQL" : "SQLite") + " database schema.");
}
}
} catch (SQLException ex) {
getLogger().severe("Unable to connect to the MySql database! Is your login information correct? Falling back to file database instead.");
ex.printStackTrace();
if (useMySql) {
getLogger().severe("Unable to connect to the MySQL database! Is your login information correct? Falling back to SQLite database instead.");
configureDatabase(false);
return;
} else {
getLogger().severe("Unable to connect to the SQLite database! This is a critical error, the plugin will be unable to save any data.");
}
}
}); // @formatter:on
}

View file

@ -31,6 +31,8 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
private static List<CommandModule> commands;
static {
commands = new ArrayList<CommandModule>();
commands.add(new AddCommandModule());
commands.add(new DataCommandModule());
commands.add(new DefaultCommandModule());

View file

@ -90,24 +90,25 @@ public class DataManager { // @formatter:off
PlayerParticles.databaseConnector.connect((connection) -> {
// Load particle groups
String groupQuery = "SELECT * FROM pp_group g WHERE g.owner_uuid = ? " +
"JOIN pp_particle p ON g.uuid = p.group_uuid";
String groupQuery = "SELECT * FROM pp_group g " +
"JOIN pp_particle p ON g.uuid = p.group_uuid " +
"WHERE g.owner_uuid = ?";
try (PreparedStatement statement = connection.prepareStatement(groupQuery)) {
statement.setString(1, playerUUID.toString());
ResultSet result = statement.executeQuery();
while (result.next()) {
// Group properties
String groupName = result.getString("g.name");
String groupName = result.getString("name");
// Particle properties
int id = result.getInt("p.id");
ParticleEffect effect = ParticleEffect.fromName(result.getString("p.effect"));
ParticleStyle style = ParticleStyleManager.styleFromString(result.getString("p.style"));
Material itemMaterial = ParticleUtils.closestMatchWithFallback(result.getString("p.item_material"));
Material blockMaterial = ParticleUtils.closestMatchWithFallback(result.getString("p.block_material"));
NoteColor noteColor = new NoteColor(result.getInt("p.note"));
OrdinaryColor color = new OrdinaryColor(result.getInt("p.r"), result.getInt("p.g"), result.getInt("p.b"));
int id = result.getInt("id");
ParticleEffect effect = ParticleEffect.fromName(result.getString("effect"));
ParticleStyle style = ParticleStyleManager.styleFromString(result.getString("style"));
Material itemMaterial = ParticleUtils.closestMatchWithFallback(result.getString("item_material"));
Material blockMaterial = ParticleUtils.closestMatchWithFallback(result.getString("block_material"));
NoteColor noteColor = new NoteColor(result.getInt("note"));
OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b"));
ParticlePair particle = new ParticlePair(playerUUID, id, effect, style, itemMaterial, blockMaterial, color, noteColor);
// Try to add particle to an existing group
@ -131,28 +132,29 @@ public class DataManager { // @formatter:off
}
// Load fixed effects
String fixedQuery = "SELECT * FROM pp_fixed f WHERE f.owner_uuid = ? " +
"JOIN pp_particle p ON f.particle_uuid = p.uuid";
String fixedQuery = "SELECT f.id AS f_id, f.world, f.xPos, f.yPos, f.zPos, p.id AS p_id, p.effect, p.style, p.item_material, p.block_material, p.note, p.r, p.g, p.b FROM pp_fixed f " +
"JOIN pp_particle p ON f.particle_uuid = p.uuid " +
"WHERE f.owner_uuid = ?";
try (PreparedStatement statement = connection.prepareStatement(fixedQuery)) {
statement.setString(1, playerUUID.toString());
ResultSet result = statement.executeQuery();
while (result.next()) {
// Fixed effect properties
int fixedEffectId = result.getInt("f.id");
String worldName = result.getString("f.world");
double xPos = result.getDouble("f.xPos");
double yPos = result.getDouble("f.yPos");
double zPos = result.getDouble("f.zPos");
int fixedEffectId = result.getInt("f_id");
String worldName = result.getString("world");
double xPos = result.getDouble("xPos");
double yPos = result.getDouble("yPos");
double zPos = result.getDouble("zPos");
// Particle properties
int particleId = result.getInt("p.id");
ParticleEffect effect = ParticleEffect.fromName(result.getString("p.effect"));
ParticleStyle style = ParticleStyleManager.styleFromString(result.getString("p.style"));
Material itemMaterial = ParticleUtils.closestMatchWithFallback(result.getString("p.item_material"));
Material blockMaterial = ParticleUtils.closestMatchWithFallback(result.getString("p.block_material"));
NoteColor noteColor = new NoteColor(result.getInt("p.note"));
OrdinaryColor color = new OrdinaryColor(result.getInt("p.r"), result.getInt("p.g"), result.getInt("p.b"));
int particleId = result.getInt("p_id");
ParticleEffect effect = ParticleEffect.fromName(result.getString("effect"));
ParticleStyle style = ParticleStyleManager.styleFromString(result.getString("style"));
Material itemMaterial = ParticleUtils.closestMatchWithFallback(result.getString("item_material"));
Material blockMaterial = ParticleUtils.closestMatchWithFallback(result.getString("block_material"));
NoteColor noteColor = new NoteColor(result.getInt("note"));
OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b"));
ParticlePair particle = new ParticlePair(playerUUID, particleId, effect, style, itemMaterial, blockMaterial, color, noteColor);
fixedParticles.add(new FixedParticleEffect(playerUUID, fixedEffectId, worldName, xPos, yPos, zPos, particle));
@ -232,8 +234,10 @@ public class DataManager { // @formatter:off
});
getPPlayer(playerUUID, (pplayer) -> {
String groupName = group.getName() == null ? "" : group.getName();
for (ParticleGroup existing : pplayer.getParticles()) {
if (existing.getName().equalsIgnoreCase(group.getName())) {
String existingName = existing.getName() == null ? "" : existing.getName();
if (groupName.equalsIgnoreCase(existingName)) {
pplayer.getParticles().remove(existing);
break;
}

View file

@ -224,14 +224,18 @@ public class LangManager {
private static YamlConfiguration configureLangFile(FileConfiguration config) {
File pluginDataFolder = PlayerParticles.getPlugin().getDataFolder();
langFileName = config.getString("lang-file");
File targetLangFile = new File(pluginDataFolder.getAbsolutePath() + File.pathSeparator + "lang" + File.pathSeparator + langFileName);
File targetLangFile = new File(pluginDataFolder.getAbsolutePath() + "/lang/" + langFileName);
if (!targetLangFile.exists()) { // Target .lang file didn't exist, default to en_US.lang
if (!langFileName.equals("en_US.lang")) {
PlayerParticles.getPlugin().getLogger().warning("Couldn't find lang file '" + langFileName + "', defaulting to en_US.lang");
}
langFileName = "en_US.lang";
targetLangFile = new File(pluginDataFolder.getAbsolutePath() + File.pathSeparator + "lang" + File.pathSeparator + langFileName);
targetLangFile = new File(pluginDataFolder.getAbsolutePath() + "/lang/" + langFileName);
if (!targetLangFile.exists()) { // en_US.lang didn't exist, create it
try (InputStream stream = PlayerParticles.getPlugin().getResource("lang/en_US.lang")) {
targetLangFile.getParentFile().mkdir(); // Make sure the directory always exists
Files.copy(stream, Paths.get(targetLangFile.getAbsolutePath()));
return YamlConfiguration.loadConfiguration(targetLangFile);
} catch (IOException ex) {

View file

@ -207,15 +207,17 @@ public enum ParticleEffect {
* @param center Center location of the effect
* @throws ParticleDataException If the particle effect requires additional data
*/
public void display(float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center) throws ParticleDataException {
public void display(double offsetX, double offsetY, double offsetZ, double speed, int amount, Location center) throws ParticleDataException {
if (hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
throw new ParticleDataException("This particle effect requires additional data");
}
for (Player player : getPlayersInRange(center))
for (Player player : getPlayersInRange(center)) {
player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed);
}
}
/**
* Displays a single particle which is colored
*
@ -260,7 +262,7 @@ public enum ParticleEffect {
* @param center Center location of the effect
* @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect
*/
public void display(Material spawnMaterial, float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center) throws ParticleDataException {
public void display(Material spawnMaterial, double offsetX, double offsetY, double offsetZ, double speed, int amount, Location center) throws ParticleDataException {
if (!hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
throw new ParticleDataException("This particle effect does not require additional data");
}

View file

@ -11,7 +11,7 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleBeam implements ParticleStyle {
private float step = 0;
private int step = 0;
private boolean reversed = false;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
@ -22,7 +22,7 @@ public class ParticleStyleBeam implements ParticleStyle {
for (int i = 0; i < points; i++) {
double angle = slice * i;
double newX = location.getX() + radius * Math.cos(angle);
double newY = location.getY() + (step / 10) - 1;
double newY = location.getY() + (step / 10D) - 1;
double newZ = location.getZ() + radius * Math.sin(angle);
particles.add(new PParticle(new Location(location.getWorld(), newX, newY, newZ)));
}

View file

@ -41,7 +41,7 @@ import com.esophose.playerparticles.util.VectorUtils;
*/
public class ParticleStyleCube implements ParticleStyle {
private float edgeLength = 2;
private double edgeLength = 2;
private double angularVelocityX = (Math.PI / 200) / 5;
private double angularVelocityY = (Math.PI / 170) / 5;
private double angularVelocityZ = (Math.PI / 155) / 5;
@ -57,7 +57,7 @@ public class ParticleStyleCube implements ParticleStyle {
xRotation = step * angularVelocityX;
yRotation = step * angularVelocityY;
zRotation = step * angularVelocityZ;
float a = edgeLength / 2;
double a = edgeLength / 2;
double angleX, angleY;
Vector v = new Vector();
for (int i = 0; i < 4; i++) {

View file

@ -11,7 +11,7 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleHalo implements ParticleStyle {
private float step = 0;
private int step = 0;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
if (step % 2 == 0) return new ArrayList<PParticle>();

View file

@ -19,113 +19,113 @@ public class ParticleStyleNone implements ParticleStyle {
switch (particleEffect) {
case AMBIENT_ENTITY_EFFECT:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case ANGRY_VILLAGER:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case BARRIER:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case BLOCK:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case BUBBLE:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case BUBBLE_COLUMN_UP:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case BUBBLE_POP:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case CLOUD:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case CRIT:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case CURRENT_DOWN:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case DAMAGE_INDICATOR:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case DOLPHIN:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case DRAGON_BREATH:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case DRIPPING_LAVA:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case DRIPPING_WATER:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case DUST:
return Collections.singletonList(new PParticle(location, 0.5F, 0.5F, 0.5F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 0.0));
case ENCHANT:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.05F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.05));
case ENCHANTED_HIT:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case END_ROD:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case ENTITY_EFFECT:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case EXPLOSION:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case EXPLOSION_EMITTER:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case FALLING_DUST:
for (int i = 0; i < 2; i++)
particles.add(new PParticle(location.add(0, 0.75, 0), 0.6F, 0.4F, 0.6F, 0.0F));
particles.add(new PParticle(location.add(0, 0.75, 0), 0.6, 0.4, 0.6, 0.0));
return particles;
case FIREWORK:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case FISHING:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case FLAME:
return Collections.singletonList(new PParticle(location, 0.1F, 0.1F, 0.1F, 0.05F));
return Collections.singletonList(new PParticle(location, 0.1, 0.1, 0.1, 0.05));
case FOOTSTEP:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case HAPPY_VILLAGER:
return Collections.singletonList(new PParticle(location, 0.5F, 0.5F, 0.5F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 0.0));
case HEART:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case INSTANT_EFFECT:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case ITEM:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case ITEM_SLIME:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case ITEM_SNOWBALL:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case LARGE_SMOKE:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case LAVA:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case MYCELIUM:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case NAUTILUS:
return Collections.singletonList(new PParticle(location, 0.5F, 0.5F, 0.5F, 0.05F));
return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 0.05));
case NONE:
return particles;
case NOTE:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case POOF:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case PORTAL:
return Collections.singletonList(new PParticle(location, 0.5F, 0.5F, 0.5F, 0.05F));
return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 0.05));
case RAIN:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case SMOKE:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case SPELL:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case SPIT:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case SPLASH:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case SQUID_INK:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case SWEEP_ATTACK:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
case TOTEM_OF_UNDYING:
return Collections.singletonList(new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0));
case UNDERWATER:
for (int i = 0; i < 5; i++)
particles.add(new PParticle(location, 0.5F, 0.5F, 0.5F, 0.0F));
particles.add(new PParticle(location, 0.5, 0.5, 0.5, 0.0));
return particles;
case WITCH:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
default:
return Collections.singletonList(new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F));
return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0));
}
}

View file

@ -11,14 +11,14 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleOrbit implements ParticleStyle {
private float step = 0;
private int step = 0;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
int orbs = 3;
List<PParticle> particles = new ArrayList<PParticle>();
for (int i = 0; i < orbs; i++) {
double dx = -(Math.cos((step / 120) * (Math.PI * 2) + (((Math.PI * 2) / orbs) * i)));
double dz = -(Math.sin((step / 120) * (Math.PI * 2) + (((Math.PI * 2) / orbs) * i)));
double dx = -(Math.cos((step / 120D) * (Math.PI * 2) + (((Math.PI * 2) / orbs) * i)));
double dz = -(Math.sin((step / 120D) * (Math.PI * 2) + (((Math.PI * 2) / orbs) * i)));
particles.add(new PParticle(new Location(location.getWorld(), location.getX() + dx, location.getY(), location.getZ() + dz)));
}
return particles;

View file

@ -11,16 +11,16 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleQuadhelix implements ParticleStyle {
private float stepX = 0;
private float stepY = 0;
private int stepX = 0;
private int stepY = 0;
private boolean reverse = false;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
for (int i = 0; i < 4; i++) {
double dx = -(Math.cos((stepX / 90) * (Math.PI * 2) + ((Math.PI / 2) * i))) * ((60 - Math.abs(stepY)) / 60);
double dy = (stepY / 60) * 1.5;
double dz = -(Math.sin((stepX / 90) * (Math.PI * 2) + ((Math.PI / 2) * i))) * ((60 - Math.abs(stepY)) / 60);
double dx = -(Math.cos((stepX / 90D) * (Math.PI * 2) + ((Math.PI / 2) * i))) * ((60 - Math.abs(stepY)) / 60);
double dy = (stepY / 60D) * 1.5;
double dz = -(Math.sin((stepX / 90D) * (Math.PI * 2) + ((Math.PI / 2) * i))) * ((60 - Math.abs(stepY)) / 60);
particles.add(new PParticle(new Location(location.getWorld(), location.getX() + dx, location.getY() + dy, location.getZ() + dz)));
}
return particles;

View file

@ -13,7 +13,7 @@ public class ParticleStyleSphere implements ParticleStyle {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
int density = 15;
float radius = 1.5f;
double radius = 1.5f;
List<PParticle> particles = new ArrayList<PParticle>();
for (int i = 0; i < density; i++) {

View file

@ -11,7 +11,7 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleSpin implements ParticleStyle {
private float step = 0;
private int step = 0;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
int points = 15;

View file

@ -16,8 +16,8 @@ public class PParticle {
* Data that determines where the particle will spawn
*/
private Location location;
private float speed;
private float xOff, yOff, zOff;
private double speed;
private double xOff, yOff, zOff;
/**
* The constructor with all the fancy parameters for customization
@ -28,7 +28,7 @@ public class PParticle {
* @param zOff The offset for the z-axis
* @param speed The speed the particle will move at
*/
public PParticle(Location location, float xOff, float yOff, float zOff, float speed) {
public PParticle(Location location, double xOff, double yOff, double zOff, double speed) {
this.location = location;
this.xOff = xOff;
this.yOff = yOff;
@ -75,7 +75,7 @@ public class PParticle {
*
* @return The particle's speed
*/
public float getSpeed() {
public double getSpeed() {
return this.speed;
}
@ -84,7 +84,7 @@ public class PParticle {
*
* @return The x-axis offset
*/
public float getXOff() {
public double getXOff() {
return this.xOff;
}
@ -93,7 +93,7 @@ public class PParticle {
*
* @return The y-axis offset
*/
public float getYOff() {
public double getYOff() {
return this.yOff;
}
@ -102,7 +102,7 @@ public class PParticle {
*
* @return The z-axis offset
*/
public float getZOff() {
public double getZOff() {
return this.zOff;
}