Skip to content

Commit

Permalink
Plugin will no longer download glyphs, they came embedded in the JAR.
Browse files Browse the repository at this point in the history
  • Loading branch information
IamTheDefender committed May 28, 2023
1 parent 387bed2 commit c7eb47c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 33 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@
<scope>system</scope>
<systemPath>${project.basedir}/lib/proxy-plugin-1.2.4.jar</systemPath>
</dependency>
<dependency>
<groupId>fr.mrmicky</groupId>
<artifactId>FastParticles</artifactId>
<version>1.2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
Expand Down Expand Up @@ -159,5 +153,11 @@
<version>5.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>xyz.xenondevs</groupId>
<artifactId>particle</artifactId>
<version>1.8.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public RarityType getRarity() {
public void execute(Player player, Location location) {
String fileLocation = config.getString(path + "file");
File file = new File(Utility.plugin().getDataFolder().getPath() + "/Glyphs/" + fileLocation);
HCore.syncScheduler().every(500, TimeUnit.MILLISECONDS).limit(10).run(()-> {
HCore.asyncScheduler().every(500, TimeUnit.MILLISECONDS).limit(10).run(()-> {
glyphUtil.sendglyphs(player, file, location);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ImageParticles
private double ratio;
private final BufferedImage image;
private final int clearence;

public ImageParticles(final BufferedImage image, final int scanQuality) {
this.particles = new HashMap<Vector, Color>();
this.anchor = new Vector(0, 0, 0);
Expand All @@ -26,15 +26,15 @@ public ImageParticles(final BufferedImage image, final int scanQuality) {
this.image = image;
this.renderParticles(Math.abs(scanQuality));
}

public void setAnchor(final int x, final int y) {
this.anchor = new Vector(x, y, 0);
}

public void setDisplayRatio(final double ratio) {
this.ratio = ratio;
}

public Map<Location, Color> getParticles(final Location location, final double pitch, final double yaw) {
final Map<Location, Color> map = new HashMap<Location, Color>();
for (final Vector vector : this.particles.keySet()) {
Expand All @@ -46,11 +46,11 @@ public Map<Location, Color> getParticles(final Location location, final double p
}
return map;
}

public Map<Location, Color> getParticles(final Location location) {
return this.getParticles(location, location.getPitch(), location.getYaw());
}

private void renderParticles(final int sensitivity) {
final int height = this.image.getHeight();
for (int width = this.image.getWidth(), x = 0; x < width; x += sensitivity) {
Expand All @@ -64,7 +64,7 @@ private void renderParticles(final int sensitivity) {
}
}
}

private Vector rotateAroundAxisX(final Vector v, double angle) {
angle = Math.toRadians(angle);
final double cos = Math.cos(angle);
Expand All @@ -73,7 +73,7 @@ private Vector rotateAroundAxisX(final Vector v, double angle) {
final double z = v.getY() * sin + v.getZ() * cos;
return v.setY(y).setZ(z);
}

private Vector rotateAroundAxisY(final Vector v, double angle) {
angle = -angle;
angle = Math.toRadians(angle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

package me.defender.cosmetics.api.category.glyphs.util;

import fr.mrmicky.fastparticle.FastParticle;
import fr.mrmicky.fastparticle.ParticleType;
import com.hakan.core.HCore;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import xyz.xenondevs.particle.ParticleBuilder;
import xyz.xenondevs.particle.ParticleEffect;
import xyz.xenondevs.particle.data.color.RegularColor;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
Expand All @@ -20,19 +22,24 @@ public class glyphUtil
public static BukkitTask task = null;

public static void sendglyphs(Player p, File file, Location loc) {
BufferedImage image = null;
try {
image = ImageIO.read(file);
}
catch (final IOException e) {
e.printStackTrace();
}
ImageParticles particles = new ImageParticles(image, 1);
particles.setAnchor(50, 10);
particles.setDisplayRatio(0.1);
Map<Location, Color> particle = particles.getParticles(loc, loc.getPitch(), 180.0);
for (Location spot : particle.keySet()) {
FastParticle.spawnParticle(p.getWorld(), ParticleType.REDSTONE, spot, 1, particle.get(spot));
BufferedImage image = null;
try {
image = ImageIO.read(file);
} catch (final IOException e) {
e.printStackTrace();
}
ImageParticles particles = new ImageParticles(image, 1);
particles.setAnchor(50, 10);
particles.setDisplayRatio(0.1);
Map<Location, Color> particle = particles.getParticles(loc, loc.getPitch(), 180.0f);
for (Location spot : particle.keySet()) {
HCore.syncScheduler().run(() -> new ParticleBuilder(ParticleEffect.REDSTONE, spot)
.setParticleData(new RegularColor(particle.get(spot).getRed(), particle.get(spot).getGreen(), particle.get(spot).getBlue()))
.display());
}
}catch (Exception exception){

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static void downloadGlyphs() {
tempFile.delete();
}
String[] filesInFolder = folder.list();
if (filesInFolder != null && filesInFolder.length != 0) {
if (filesInFolder != null && filesInFolder.length == 0) {
return;
}
JavaPlugin plugin = Utility.plugin();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.defender.cosmetics.listener;

import com.hakan.core.HCore;
import me.defender.cosmetics.api.BwcAPI;
import me.defender.cosmetics.api.util.Utility;
import org.bukkit.event.EventHandler;
Expand All @@ -12,9 +13,12 @@ public class PlayerLeaveListener implements Listener {
public void onLeave(PlayerQuitEvent e){
BwcAPI api = new BwcAPI();
// Saving for SQLite will be on shutdown.
if(api.isMySQL()) {
Utility.playerDataList.get(e.getPlayer().getUniqueId()).save();
Utility.playerOwnedDataList.get(e.getPlayer().getUniqueId()).save();
if(api.isMySQL() && Utility.playerDataList.containsKey(e.getPlayer().getUniqueId())) {
HCore.asyncScheduler().run(() -> Utility.playerDataList.get(e.getPlayer().getUniqueId()).save());
// Didn't use && for playerOwnedData because it's okay for it to be null, I guess...
if(Utility.playerOwnedDataList.containsKey(e.getPlayer().getUniqueId())) {
HCore.asyncScheduler().run(() -> Utility.playerOwnedDataList.get(e.getPlayer().getUniqueId()).save());
}
}
}
}

0 comments on commit c7eb47c

Please sign in to comment.