Created Sprint Artifact extension

This commit is contained in:
Auxilor 2020-11-25 13:15:28 +00:00
parent ed16dde180
commit f77532399d
37 changed files with 121 additions and 38 deletions

View File

@ -0,0 +1,14 @@
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT'
compileOnly project(':plugin')
}
jar{
archiveFileName = project.name + " Extension" + ".jar"
}
description = 'Sprint Artifacts'
tasks.withType(Jar) {
destinationDirectory = file("$rootDir/bin/")
}

View File

@ -0,0 +1,45 @@
package com.willfp.ecoenchants.sprintartifacts;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
import org.bukkit.Location;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.Vector;
import java.util.Objects;
import java.util.Optional;
public class SprintArtifactsListener implements Listener {
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if(!player.isSprinting()) return;
if(!player.isOnGround()) return;
ItemStack boots = player.getInventory().getBoots();
if(boots == null) return;
ItemMeta bootsMeta = boots.getItemMeta();
if(bootsMeta == null) return;
Optional<EcoEnchant> matching = bootsMeta.getEnchants().keySet().stream()
.map(EcoEnchants::getFromEnchantment)
.filter(Objects::nonNull)
.filter(enchantment -> enchantment.getType().equals(EcoEnchant.EnchantmentType.ARTIFACT))
.findFirst();
if(!matching.isPresent()) return;
Artifact artifact = (Artifact) matching.get();
if (!EnchantChecks.chestplate(player, artifact)) return;
player.getWorld().spawnParticle(artifact.getParticle(), player.getLocation().add(0, 0.1, 0), 1, 0, 0, 0, 0, artifact.getDustOptions(), true);
}
}

View File

@ -0,0 +1,17 @@
package com.willfp.ecoenchants.sprintartifacts;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.extensions.Extension;
import org.bukkit.Bukkit;
public class SprintArtifactsMain extends Extension {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(new SprintArtifactsListener(), EcoEnchantsPlugin.getInstance());
}
@Override
public void onDisable() {
}
}

View File

@ -0,0 +1,3 @@
name: Sprint Artifacts
main: com.willfp.ecoenchants.sprintartifacts.SprintArtifactsMain
version: 1.0.0

View File

@ -13,7 +13,7 @@ public class AshArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.WHITE_ASH;
}
}

View File

@ -11,12 +11,12 @@ public class CloudsArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.REDSTONE;
}
@Override
protected Particle.DustOptions getDustOptions() {
public Particle.DustOptions getDustOptions() {
return new Particle.DustOptions(Color.AQUA, 1.0f);
}
}

View File

@ -13,7 +13,7 @@ public class CrimsonArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.CRIMSON_SPORE;
}
}

View File

@ -10,7 +10,7 @@ public class DamageArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.DAMAGE_INDICATOR;
}
}

View File

@ -10,7 +10,7 @@ public class DragonArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.DRAGON_BREATH;
}
}

View File

@ -10,7 +10,7 @@ public class DustArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.CRIT;
}
}

View File

@ -10,7 +10,7 @@ public class EmeraldArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.COMPOSTER;
}
}

View File

@ -10,7 +10,7 @@ public class EnchantmentArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.ENCHANTMENT_TABLE;
}
}

View File

@ -10,7 +10,7 @@ public class EndArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.END_ROD;
}
}

View File

@ -10,7 +10,7 @@ public class FireArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.FLAME;
}
}

View File

@ -10,7 +10,7 @@ public class HeartArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.HEART;
}
}

View File

@ -10,7 +10,7 @@ public class HoneyArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.FALLING_HONEY;
}
}

View File

@ -10,7 +10,7 @@ public class InkArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.SQUID_INK;
}
}

View File

@ -10,7 +10,7 @@ public class LavaArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.DRIP_LAVA;
}
}

View File

@ -12,12 +12,12 @@ public class LimeArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.REDSTONE;
}
@Override
protected Particle.DustOptions getDustOptions() {
public Particle.DustOptions getDustOptions() {
return new Particle.DustOptions(Color.fromRGB(3, 252, 140), 1.0f);
}
}

View File

@ -10,7 +10,7 @@ public class MagicArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.CRIT_MAGIC;
}
}

View File

@ -10,7 +10,7 @@ public class MagmaArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.LAVA;
}
}

View File

@ -10,7 +10,7 @@ public class MusicArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.NOTE;
}
}

View File

@ -10,7 +10,7 @@ public class NetherArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.PORTAL;
}
}

View File

@ -11,12 +11,12 @@ public class RedstoneArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.REDSTONE;
}
@Override
protected Particle.DustOptions getDustOptions() {
public Particle.DustOptions getDustOptions() {
return new Particle.DustOptions(Color.RED, 1.0f);
}
}

View File

@ -10,7 +10,7 @@ public class SmokeArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.CAMPFIRE_COSY_SMOKE;
}
}

View File

@ -10,7 +10,7 @@ public class SnowArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.SNOWBALL;
}
}

View File

@ -13,7 +13,7 @@ public class SoulArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.SOUL;
}
}

View File

@ -13,7 +13,7 @@ public class SoulFireArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.SOUL_FIRE_FLAME;
}
}

View File

@ -10,7 +10,7 @@ public class SparkleArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.FIREWORKS_SPARK;
}
}

View File

@ -13,7 +13,7 @@ public class TearArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.DRIPPING_OBSIDIAN_TEAR;
}
}

View File

@ -10,7 +10,7 @@ public class TotemArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.TOTEM;
}
}

View File

@ -13,7 +13,7 @@ public class WarpedArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.WARPED_SPORE;
}
}

View File

@ -10,7 +10,7 @@ public class WaterArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.DRIP_WATER;
}
}

View File

@ -10,7 +10,7 @@ public class WitchArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.SPELL_WITCH;
}
}

View File

@ -11,12 +11,12 @@ public class ZapArtifact extends Artifact {
}
@Override
protected Particle getParticle() {
public Particle getParticle() {
return Particle.REDSTONE;
}
@Override
protected Particle.DustOptions getDustOptions() {
public Particle.DustOptions getDustOptions() {
return new Particle.DustOptions(Color.YELLOW, 1.0f);
}
}

View File

@ -50,9 +50,9 @@ public abstract class Artifact extends EcoEnchant {
}
protected abstract Particle getParticle();
public abstract Particle getParticle();
protected Particle.DustOptions getDustOptions() {
public Particle.DustOptions getDustOptions() {
return null;
};

View File

@ -30,4 +30,8 @@ include('Endershot')
findProject(':Endershot').projectDir = file('Extensions/Endershot')
include('Biomes')
findProject(':Biomes').projectDir = file('Extensions/Biomes')
findProject(':Biomes').projectDir = file('Extensions/Biomes')
include('SprintArtifacts')
findProject(':SprintArtifacts').projectDir = file('Extensions/SprintArtifacts')