BLEEDING EDGE v1.3_02

This commit is contained in:
Paldiu 2021-02-26 22:32:01 -06:00
parent 549187b450
commit 9bb8902eed
7 changed files with 173 additions and 4 deletions

View File

@ -28,6 +28,8 @@ dependencies {
//provided //provided
[ [
"com.destroystokyo.paper:paper-api:1.16.4-R0.1-SNAPSHOT", "com.destroystokyo.paper:paper-api:1.16.4-R0.1-SNAPSHOT",
"net.md-5:bungeecord-api:1.16-R0.4-SNAPSHOT",
"io.github.waterfallmc:waterfall-api:1.16-R0.4-SNAPSHOT",
"me.clip:placeholderapi:2.10.9", "me.clip:placeholderapi:2.10.9",
].each {s -> ].each {s ->
compileOnly s compileOnly s

View File

@ -1,12 +1,18 @@
package io.github.simplexdev.api; package io.github.simplexdev.api;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.Particle; import org.bukkit.Particle;
public interface IParticleEffect { import java.util.Map;
Particle[] getParticles(); import java.util.Set;
Color[] getParticleColors(); public interface IParticleEffect {
Set<Particle> getParticles();
Map<Particle, Color> getParticleColors();
Set<Effect> getEffects();
Float getSize(); Float getSize();

View File

@ -0,0 +1,16 @@
package io.github.simplexdev.api.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ServerInfo {
boolean isPaper() default false;
boolean isWaterfall() default false;
boolean isBungeeCord() default false;
}

View File

@ -0,0 +1,93 @@
package io.github.simplexdev.simplexcore.particle;
import io.github.simplexdev.api.IParticleEffect;
import org.bukkit.*;
import java.util.*;
public class ParticleFactory {
private float size = 2F;
private long duration = 20L * 15L;
private final Set<Particle> particleSet = new HashSet<>();
private final Map<Particle, Color> particleColorMap = new HashMap<>();
private final Set<Effect> particleEffects = new HashSet<>();
public ParticleFactory() {
}
public ParticleFactory setSize(float size) {
this.size = size;
return this;
}
public ParticleFactory setDuration(long duration) {
this.duration = duration;
return this;
}
public ParticleFactory setParticles(Particle... particles) {
Collections.addAll(particleSet, particles);
return this;
}
public ParticleFactory setParticleColor(Particle particle, Color color) {
particleColorMap.put(particle, color);
return this;
}
/**
* Sets a color for more than one particle.
* @param color
* @param particles
* @return
*/
public ParticleFactory setMultipleParticleColors(Color color, Particle... particles) {
for (Particle particle : particles) {
particleColorMap.put(particle, color);
}
return this;
}
public ParticleFactory setParticleEffects(Effect... effects) {
particleEffects.addAll(Arrays.asList(effects));
return this;
}
public IParticleEffect create() {
return new IParticleEffect() {
@Override
public Set<Particle> getParticles() {
return particleSet;
}
@Override
public Map<Particle, Color> getParticleColors() {
return particleColorMap;
}
@Override
public Set<Effect> getEffects() {
return particleEffects;
}
@Override
public Float getSize() {
return size;
}
@Override
public Long getDuration() {
return duration;
}
};
}
// TODO: Needs work :)
public void spawnParticle(IParticleEffect effect, Location location) {
World world = location.getWorld();
effect.getParticles().forEach(particle -> {
Color color = effect.getParticleColors().get(particle);
world.spawnParticle(particle, location, 20);
});
}
}

View File

@ -1,5 +1,9 @@
package io.github.simplexdev.simplexcore.plugin; package io.github.simplexdev.simplexcore.plugin;
import io.github.simplexdev.api.annotations.ServerInfo;
import io.github.simplexdev.api.func.Guard;
import io.github.simplexdev.simplexcore.utils.Constants;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -14,7 +18,52 @@ public final class AddonRegistry {
return instance; return instance;
} }
public <T extends SimplexAddon<T>> boolean isPaper(T addon) {
try {
Class.forName(com.destroystokyo.paper.Namespaced.class.getName());
return true;
} catch (ClassNotFoundException ignored) {
addon.stop();
Constants.getLogger().severe(addon.getName() + " has been disabled: This module requires Paper!");
return false;
}
}
private <T extends SimplexAddon<T>> boolean isBungee(T addon) {
try {
Class.forName(net.md_5.bungee.Util.class.getName());
return true;
} catch (ClassNotFoundException ignored) {
addon.stop();
Constants.getLogger().severe(addon.getName() + " has been disabled: This module requires Bungeecord!");
return false;
}
}
private <T extends SimplexAddon<T>> boolean isWaterfall(T addon) {
try {
Class.forName(io.github.waterfallmc.waterfall.utils.Hex.class.getName());
return true;
} catch (ClassNotFoundException ignored) {
addon.stop();
Constants.getLogger().severe(addon.getName() + " has been disabled: This module requires Waterfall!");
return false;
}
}
public <T extends SimplexAddon<T>> void register(T addon) { public <T extends SimplexAddon<T>> void register(T addon) {
if (addon.getClass().isAnnotationPresent(ServerInfo.class)) {
ServerInfo info = addon.getClass().getDeclaredAnnotation(ServerInfo.class);
if (info.isPaper() && !isPaper(addon)) {
return;
}
if (info.isBungeeCord() && !isBungee(addon)) {
return;
}
if (info.isWaterfall() && !isWaterfall(addon)) {
return;
}
}
getComponents().add(addon); getComponents().add(addon);
} }

View File

@ -6,7 +6,7 @@ import io.github.simplexdev.simplexcore.config.YamlFactory;
import io.github.simplexdev.simplexcore.plugin.AddonRegistry; import io.github.simplexdev.simplexcore.plugin.AddonRegistry;
import io.github.simplexdev.simplexcore.plugin.DependencyManagement; import io.github.simplexdev.simplexcore.plugin.DependencyManagement;
public class Instances { public final class Instances {
private final DependencyManagement dpm = new DependencyManagement(); private final DependencyManagement dpm = new DependencyManagement();
private final Yaml config = new YamlFactory(Constants.getPlugin()).setDefaultPathways(); private final Yaml config = new YamlFactory(Constants.getPlugin()).setDefaultPathways();
private final TimeValues time = new TimeValues(); private final TimeValues time = new TimeValues();

View File

@ -7,3 +7,6 @@ authors:
- Paldiu - Paldiu
- Conclure - Conclure
description: Core for a group of plugins designed to enhance gameplay to the max description: Core for a group of plugins designed to enhance gameplay to the max
softdepend:
- PlaceholderAPI
- ProtocolLib